Problem:
How to to generate a copyfile for an XML document for which only a Document Type Definition (DTD) file is being used to describe the data elements in the document.
Resolution:
The CBL2XML tool cannot use a .DTD file in the production of a copybook. The Document Type Definition (DTD) file needs to be converted to a schema in order to be usable with CBL2XML.
There are many 3rd party tools that can do this automatically, including a product called Stylus Studio. If you use Stylus Studio, and click on File>Document Wizards, you can select "DTD to XML Schema". Load your DTD and it will be converted to a corresponding XSD schema file.
A DTD file does not allow for different data types and lengths to be specified for elements and attributes within a document, so the Schema that is generated will have all elements defined as a string type with an unbounded length.
Add the following line to the beginning of the generated schema .XSD file:
<?xml version="1.0"?>
This is required by CBL2XML.
Place the new .XSD file in the same folder as the XML document that requires it.
You will also have to modify the .XML document file so that it references the new schema.
Change the first two lines:
(assuming that the root element is LETTEROUTPUT and newfile.xsd is the name of the schema)
<!DOCTYPE LETTEROUTPUT SYSTEM "oldfile.DTD">
<LETTEROUTPUT>
to:
<?xml version="1.0"?>
<LETTEROUTPUT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:nonamespaceSchemaLocation="newfile.xsd">
Then save the file.
CBL2XML will convert these elements to COBOL PIC X(80) but if you know the actual data type and lengths for these elements, you can modify the generated copybook file with your own data definitions.