Problem:
Would like to use CBL2XML to generate the copybook for an XML document that has multiple record definitions at the element level, depending on the value in a contained attribute.
Resolution:
The CBL2XML tool has a restriction on this type of construct. It will only generate the record description for the first record type specified in the schema. It will ignore any multiple record types or redefinitions of elements.
This is a restriction in CBL2XML only, and not in the XML support provided by Net Express.
The XML syntax support does provide for this type of redefinition in two different ways. Both ways are documented, with example code, in the Net Express On-Line Help.
The first method is to use variables as tag names and values so that you can read any type of XML layout, and receive the names of the tags that are found, along with the corresponding data. This allows you to read an XML document without any knowledge of its schema layout.
This is shown in the example under the IDENTIFIED BY and IS ATTRIBUTE section.
The other method is to define two 01 level record descriptions under the XD for the XML file, and use the values within the COUNT-IN variables to determine which record has been read.
This is shown in the example under the COUNT-IN phrase.
The online example determines whether a book or an author record was read, based on the COUNT-IN value for the 01 record levels tag value.