Transforming XML to application data

You can write an application program to transform XML to application data. You can also query the XML before transforming it.

Before you begin

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

About this task

The CICS XML assistant generates the mappings in the XML binding. If you started with a language structure and used DFHLS2SC, only one transformation from 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 language structure to use as output.

Procedure

  1. Create a channel and place the XML into a text mode container on that channel.
    If the application puts the XML in a BIT mode container, CICS tries to determine the encoding of the text data, but it can take longer to process the container and the encoding might not be correct.
  2. Use the TRANSFORM XMLTODATA API command.
    If only one transform is possible for the XML, you can use the following command:
    EXEC CICS TRANSFORM XMLTODATA
          XMLTRANSFORM('MyXmlTransformName')
          CHANNEL('MyChannelName')
          XMLCONTAINER('SourceContainerName')
          DATCONTAINER('TargetContainerName')
          
    If more than one transformation is possible, use the following additional options:
    EXEC CICS TRANSFORM XMLTODATA
          XMLTRANSFORM('MyXmlTransformName')
          CHANNEL('MyChannelName')
          XMLCONTAINER('SourceContainerName')
          DATCONTAINER('TargetContainerName')
          ELEMNAME(elementName) ELEMNAMELEN(elementNameLength)      
    In the second example, CICS returns the name of the element that was found in the ELEMNAME option. The application can then use the name of the element to determine which of the library of language structures to use to interpret the contents of the target container.
  3. Install the application program.

Results

When the application runs the TRANSFORM XMLTODATA command, CICS uses the details in the XMLTRANSFORM resource to transform the XML to application binary data using the containers on the channel.

Example

What to do next

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