Skip to main content

Problem:

How can I export a large number of repeating data elements in XML?

Resolution:

Some uses of XML manipulate large documents that consist of a large number of repetitions of a few data items.  An example of this is the ability of many relational database packages to output result sets as rows encoded in XML.  

One very straightforward way to create these large documents is to use the LINE SEQUENTIAL file access method and COBOL procedural statements such as STRING to create text records.  For simple applications where requirements are well understood and stable, this approach should work well.

The attached example uses a different approach.  The output is segmented into pieces that can be conveniently accommodated in a COBOL array (using the OCCURS clause).  These pieces are then exported, using XML EXPORT FILE, into a temporary XML documents.  Finally, when all the pieces have been exported, the temporary documents are merged together into a final document.

This approach is advantageous when the final result might have several variations (which can be accommodated by the final XSLT), or where the repeated data structure is more complicated than a simple 'row' (where the COBOL code designed to write the information to a file becomes too complex).

    

Attachments:

mergexml.zip

Old KB# 4711