XML EXPORT FILE

This statement has the following parameters:

Parameter Description
DataItem The name of the COBOL data item that contains data to be exported.
DocumentName The name of a file that will receive the exported XML document.
ModelFileName#DataFileName This parameter may be either of the following:
  • The name of the data structure. If the # (hash) character is missing, it is assumed that the hash character was intended to be placed at the beginning of the parameter (as the specified name is a data item name). Previously, it was assumed that the # character was placed at the end of the parameter (as the specified name was a filename).

    Everything to the left of the "#" character is the filename. Everything to the right is the data structure name. Either component is optional; that is, model names of "file#", "file", "#data", "#" and "" are allowed. If the filename is omitted and a default has not been provided from the XML COBOL FILE-NAME statement|tag=XML COBOL FILE-NAME, then the current program is assumed. If the data name is not found, then calling programs are used (in order of the call stack).

    If the data name is omitted, then the entire program is used.

    If a hash "#" character is missing from the ModelFileName parameter, one will be assumed to be present at the beginning (the ModelFileName is assumed to be a data name).

    Furthermore, a hierarchical specification of data names may be used; that is, "file#a//b//c" is valid. It has the same meaning as the COBOL specification of "C of B of A". Either data names or program names may be specified in the data name hierarchy; that is, A and B could be the names of programs, assuming B is a program contained in A.

  • The name of the set of XML files produced by the XMLGEN compiler directive that describe the COBOL data item. For more information, see Model Files.
[StyleSheetName] Optional. The name of an external XSLT stylesheet that will be used to transform the generated XML document before it is stored.

Description

The XML EXPORT FILE statement exports the content of the COBOL data item indicated by the DataItem parameter. The content of the data item is converted to an XML document using one or more files indicated by the ModelFileName#DataFileName parameter. The output of this conversion is to the file specified by the DocumentName parameter. If the optional StyleSheetName parameter is present, the external XSLT stylesheet is used to transform the document after it has been generated but before it is stored in the data file.

A status value is returned in the XML-data-group data item, which is defined in the copybook, lixmldef.cpy.

Examples

Without an External XSLT Stylesheet:

XML EXPORT FILE
    MY-DATA-ITEM
    "MY-DOCUMENT"
    "MY-MODEL-FILE".
IF NOT XML-OK GO TO Z.

With an External XSLT Stylesheet:

XML EXPORT FILE
    MY-DATA-ITEM
    "MY-DOCUMENT.XML"
    "MY-MODEL-FILE"
    "MY-STYLE-SHEET" 
IF NOT XML-OK GO TO Z.

With an External XSLT Stylesheet and Parameters:

XML SET XSL-PARAMETERS
     "MY-COUNT", 7.
IF NOT XML-OK GO TO Z.
XML EXPORT FILE
    MY-DATA-ITEM
    "MY-DOCUMENT.XML"
    "MY-MODEL-FILE"
    "MY-STYLE-SHEET"
IF NOT XML-OK GO TO Z