XML EXPORT TEXT

This statement has the following parameters:

Parameter Description
DataItem An identifier of the COBOL data item that contains the data to be exported. This is not necessarily the same data item as the one that produced the model template file description of the data to be exported, but must be at least as large as so described. The identifier may refer to a linkage data item that has been passed to a subprogram that does the export. The identifier may be that of a table element specified with any necessary subscripting or indexing when the application has a table of export areas.
DocumentPointer An identifier of a COBOL pointer data item that will point to the generated XML document as a text string after successful completion of the statement.
DocumentLength An identifier of a COBOL numeric data item that will contain the length of the generated XML document pointed to by DocumentPointer after successful completion of the statement.
ModelFileName#DataName A nonnumeric literal or an identifier of an alphanumeric data item, the value of which may be any 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).

    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 (on page 41), then the current program is assumed. If the data name is not found, then calling programs are used (in order of the call stack).

    The data name must be found in the model template file; its description must not describe an area larger than the DataItem specified by the first parameter of the statement; otherwise an error 74 may happen during program execution. If the data name is omitted in this parameter, then the entire program's data definitions are used as determined by the model template file.

    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, "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 XML file produced by the XMLGEN compiler directive that describe the COBOL data item. For more information, see Model Files.
[StyleSheetName] A nonnumeric literal or an identifier of an alphanumeric data item, the value of which is the name of a file containing an XSLT stylesheet that will be used to transform the generated XML document before it is stored.

Description

The XML EXPORT TEXT 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#DataName parameter, and then it is output as a text string. The address and size of the text string is placed in the COBOL data items specified by the DocumentPointer and DocumentLength parameters. 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 as a text string.

A block of memory is allocated to hold the generated XML document. The descriptor of this memory block overrides any existing address descriptor in the COBOL pointer data item. The COBOL application is responsible for releasing this memory when it is no longer needed by using XML FREE TEXT.

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 TEXT
    MY-DATA-ITEM
    MY-DOCUMENT-POINTER
    MY-DOCUMENT-LENGTH
    "MY-MODEL-FILE".
IF NOT XML-OK GO TO Z.

With an External XSLT Stylesheet:

XML EXPORT TEXT
    MY-DATA-ITEM
    MY-DOCUMENT-POINTER
    MY-DOCUMENT-LENGTH
    "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 TEXT
    MY-DATA-ITEM
    "MY-DOCUMENT.XML"
    "MY-MODEL-FILE"
    "MY-STYLE-SHEET"
IF NOT XML-OK GO TO Z.