If the XML schema contains global data types, one or more
of which are referenced in the XML, you can generate metadata to support
these global data types and then parse or transform the XML in an
application program.
Before you begin
To generate the correct metadata, you must run DFHSC2LS specifying
the
TYPES=ALL
parameter.
Procedure
- To transform application data to XML by data type, use
the
TRANSFORM DATATOXML
command:
EXEC CICS TRANSFORM DATATOXML
XMLTRANSFORM('
MyXmlTransformName
')
CHANNEL('
MyChannelName
')
DATCONTAINER('
SourceContainerName
')
XMLCONTAINER('
TargetContainerName
')
ELEMNAME(
elementName
) ELEMNAMELEN(
elementNameLength
)
ELEMNS(
elementNamespace
) ELEMNSLEN(
elementNamespaceLength
)
TYPENAME(
typeName
) TYPENAMELEN(
typeNameLen
)
TYPENS(
typeNamespace
) TYPENSLEN(
typeNamespaceLen
)
MyXmlTransformName
is
the 32-character name of the XMLTRANSFORM resource that specifies
the XML binding and schema;
MyChannelName
is the
16-character name of the channel that has the input and output containers;
SourceContainerName
is
the 16-character name of the input container that holds the
application
data and
TargetContainerName
is the 16-character
name of the output container that CICS populates with XML. You must
also specify the XML element name, the namespace, the data type,
and
the namespace of the data type for the transformation.
- To parse the XML by data type, use the
TRANSFORM
XMLTODATA
command.
The options that you specify
on the command depend on whether the XML has an xsi:type attribute.
- If the XML uses the xsi:type attribute, specify the following
command in your application program:
EXEC CICS TRANSFORM XMLTODATA
XMLTRANSFORM('
MyXmlTransformName
')
CHANNEL('
MyChannelName
')
XMLCONTAINER('
SourceContainerName
')
DATCONTAINER('
TargetContainerName
')
ELEMNAME(elementName) ELEMNAMELEN(elementNameLength)
TYPENAME(typeName) TYPENAMELEN(typeNameLength)
If the application also requires the namespace of the
data type, add the TYPENS option to the API command. CICS returns
the data type from the xsi:type attribute in TYPENAME.
- If the XML does not use the xsi:type attribute, the application
program can specify the local name and namespace of the global
data
type. Use the following command in your application program:
EXEC CICS TRANSFORM XMLTODATA
XMLTRANSFORM('
MyXmlTransformName
')
CHANNEL('
MyChannelName
')
XMLCONTAINER('
SourceContainerName
')
DATCONTAINER('
TargetContainerName
')
TYPENAME(
typeName
) TYPENAMELEN(
typeNameLength
)
TYPENS(
TypeNamespace
) TYPENSLEN(
typeNamespaceLen
)
The
application program must specify the type name and namespace but not
the name and namespace. This command indicates that the application
tells CICS which data type to use. When CICS is generating XML,
CICS
always adds the xsi:type attribute.
- Install the application program in CICS.
What to do next
Test that the application program generates and parses the
XML as expected.