Transforming application data to XML

You can write an application program to transform application data to XML.

Before you begin

You must have an enabled XMLTRANSFORM resource that defines the XML binding and XML schema.

About this task

The XML assistant generates the mappings in the XML binding. If you started with a language structure and used DFHLS2SC, only one transformation to the XML is possible. If you started with an XML schema, there might be many XML to language structure transformations so your application must select which XML element to generate.

Procedure

  1. The application program must create a channel and place the data associated with the language structure into a bit-mode container on that channel.
  2. Use the TRANSFORM DATATOXML API command to transform the data to XML:
    EXEC CICS TRANSFORM DATATOXML
         XMLTRANSFORM('MyXmlTransformName')
         CHANNEL('MyChannelName')
         DATCONTAINER('SourceContainerName')
         XMLCONTAINER('TargetContainerName')
    
    If the XMLTRANSFORM resource supports only a single transformation from the language structure, you do not have to specify the conversion type on the command. If many transformations are possible, add the following options to your application program:
    ELEMNAME(elementName) ELEMNAMELEN(elementNameLength)
    These additional options indicate the XML element into which the application data is transformed and placed in the output container.
  3. Install the application program.

Results

When the application runs the TRANSFORM DATATOXML command, CICS checks the XMLTRANSFORM resource to find the mappings in the XML binding and transforms the application binary data to XML using the containers on the channel. The XML is placed in the container that the application specified on the XMLCONTAINER option. The XML conforms to the XML schema that is defined in the XMLTRANSFORM resource.

What to do next

You can also use the same mappings to transform XML to application data. For details, see Transforming XML to application data.