Hi Fady,
I generated transformers for a copybook using the following code
Cob2TransGenerator cob2trans = new Cob2TransGenerator( new Cob2TransModel());
Cob2TransResult result = cob2trans.generate(cobolFile, target,classpath);
Using the generated classes tried to convert a fixlength to xml, below is the code.
Path path = Paths.get("C:\\AccountBalanceRequest.txt");
byte[] hostData = Files.readAllBytes(path);
StringWriter writer = new StringWriter();
AccountBalanceRequestXmlTransformers transformers = new AccountBalanceRequestXmlTransformers();
transformers.toXml(hostData, writer);
System.out.println(writer.toString());
In the xml it is showing some garbage data shown below in red.
Could you please tell me what I'm doing wrong.
COPYBOOK
"
01 ACCOUNT-BALANCE-REQUEST.
05 TRANSACTION PIC X(4) COMP.
05 TOKEN PIC X(24) COMP.
05 ACCT-NUM PIC S9(5) COMP-4.
"
GENERATED XSD
"
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
elementFormDefault="unqualified">
<xsd:complexType name="AccountBalanceRequest">
<xsd:sequence>
<xsd:element name="transaction">
<xsd:annotation>
<xsd:appinfo>
<cb:cobolElement cobolName="TRANSACTION"
levelNumber="5"
picture="X(4)"
srceLine="2"
type="ALPHANUMERIC_ITEM"
usage="BINARY"/>
</xsd:appinfo>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="4"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="token">
<xsd:annotation>
<xsd:appinfo>
<cb:cobolElement cobolName="TOKEN"
levelNumber="5"
picture="X(24)"
srceLine="3"
type="ALPHANUMERIC_ITEM"
usage="BINARY"/>
</xsd:appinfo>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="24"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="acctNum">
<xsd:annotation>
<xsd:appinfo>
<cb:cobolElement cobolName="ACCT-NUM"
levelNumber="5"
picture="S9(5)"
signed="true"
srceLine="4"
totalDigits="5"
type="BINARY_ITEM"
usage="BINARY"/>
</xsd:appinfo>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:int">
<xsd:totalDigits value="5"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="accountBalanceRequest" type="AccountBalanceRequest">
<xsd:annotation>
<xsd:appinfo>
<cb:cobolElement cobolName="ACCOUNT-BALANCE-REQUEST"
levelNumber="1"
srceLine="1"
type="GROUP_ITEM"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:schema>
"
HOST DATA (AccountBalanceRequest.txt)
gtabac38475928dcfbaee98cfc8d12345
xml generated
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns2:AccountBalanceRequest xmlns:ns2="$coxbHelper.getXmlNamespace($binding)"><transaction>ÅÈ/Â</transaction><token>/Ä??? ?? ?ÀÄÃÂ/ÁÁ??ÄÃÄ?À</token><acctNum>825373492</acctNum></ns2:AccountBalanceRequest>