You can compose XML output within the node for an action by using data that’s returned by a previous event or action in an IBM App Connect flow. XML uses a universal format to store and transport structured data, and the “XML compose” function can be used to facilitate the distribution of this data between two integrating applications in a flow.

From your flows, you can select XML as the target format for any string field (identified by the abc notation) in an action node, and then define a structure and content for the XML output.

Select XML as a target format

To define the XML output, you import an XML Schema Definition (XSD) file that defines an XML document structure to base your output on. The string field’s format is converted to XML after the file is imported, and the XML elements in the imported file are exposed as nested fields that conform to the structure and data types that are defined in the file. After you map these fields to data from previous modes, XML output is constructed “in memory” and gets written to the target application when you run the flow. Possible use cases for the XML compose function might be to create XML files in file management applications or in CRM applications that support the creation of attachments.

Guidelines and restrictions for the XSD import

Review these guidelines and restrictions to see which schema definitions are supported in XSD files that you want to import.

  • A single XSD file with a single namespace definition is supported. Multiple XSD files in a ZIP archive are not currently supported.
  • The following elements are not supported:
    • xsd:import (imports schema components from a different namespace into an XSD document)
    • xsd:include (imports schema components that are in the same namespace)
    • xsd:redefine (redefines simple and complex types, groups, and attribute groups obtained from external schema)
  • Schemas that include references must specify a target namespace in order to be rendered correctly.
  • targetclass is not supported.
  • xsd:choice child elements are merged, allowing access to all the child elements instead of providing a choice of only one.
  • References are followed and expanded until they become recursive structures.
  • Adding $xsiType as an attribute in your JSON will allow you to specify an override or an exact namespace and type for any complexType element that has been extended or restricted. For example:
    'Address': {
            '$attributes': {
              '$xsiType': {
                'type': 'overrideType',
                'xmlns': 'overrideNS'
            'HouseNumber': 23

Defining the structure and content of your XML output

We’ll use a simple scenario to describe how you can compose XML output from a field in your flow. Let’s suppose you want to extract shipping details that are recorded for orders in a database so that you can save them to an XML file in Box for some further action. You have constructed a flow that includes an IBM Db2 “Retrieve TABLE records” action for the data to be retrieved.

  • Example: Db2 shipping records to be retrieved and Db2 “retrieve records” action

    Example of Db2 shipping records to be retrieved

    Db2 retrieve action example

As the next step, you are going to add a Box action to create a file with a .xml file extension, and then generate an XML schema that defines the structure and content of your XML file. To generate this schema, you’ll need an XSD file that describes the elements for the XML content.

  1. From the Box node for the “Create file” action, specify the folder where you want to save the file, and then add a name of the XML file to be created.

    Folder and file name selection in the Box node

  2. In the File content field, click abc and then select XML. (This is the field that you want to use to compose your XML content.)

    Select XML as the format for a string field

  3. In the “XML schema settings” panel, either drag and drop the XSD file from its location in an open file browser into the boxed area, or click within the boxed area to open a file browser and locate the .xsd file. You’ll see the file name in the boxed area.

    Example of an XSD file in the boxed area for import

    • Sample XSD contents (customized from

      <?xml version="1.0" encoding="UTF-8" ?>
      <xs:schema xmlns:xs="" targetNamespace="fionasnamespace">
        <xs:element name="shiporders">
        <xs:element name="shiporder" maxOccurs="unbounded">
              <xs:element name="orderperson" type="xs:string"/>
              <xs:element name="shipto">
                    <xs:element name="name" type="xs:string"/>
                    <xs:element name="address" type="xs:string"/>
                    <xs:element name="city" type="xs:string"/>
                    <xs:element name="country" type="xs:string"/>
              <xs:element name="item">
                    <xs:element name="title" type="xs:string"/>
                    <xs:element name="note" type="xs:string" minOccurs="0"/>
                    <xs:element name="quantity" type="xs:positiveInteger"/>
                    <xs:element name="price" type="xs:decimal"/>
            <xs:attribute name="orderid" type="xs:string" use="required"/>

  4. If the XSD file contains global elements, select a global element name from the Global element drop-down list to identify which portion of the schema should be used to define the XML output structure. (XSD files with a single global element will show that element name by default.)
  5. Click Import to display a field-based representation of the XML elements and structure.

    Field-based representation of the XML elements and structure

  6. Define the XML data content by mapping to the Db2 fields.

    XML fields mapped to Db2 fields

  7. To change the structure, field labels, or data types defined for the exposed nested fields , click Regenerate schema. (Note that you will lose any mappings that are currently defined.) In the “XML schema settings” panel, clear any previous setting, and then add an XSD file with the required XML schema.
  8. If you are sending the XML output to a file, be sure to indicate that the file type should be text (rather than binary).

When you run the flow, you should obtain a XML file with the specified structure and format. The following image shows an XML file that was generated for the scenario described above.

Generated XML file in Box

Example: Processing the generated XML output

The XML output that the XML compose function generates can be used in any number of ways to complete an action in the same or a different flow, or used externally. Let’s suppose that you’d like to use the .xml file that was generated in the scenario above to create shipping records for orders within some other application.

Using App Connect, you can add a Box “Retrieve file” action to a flow, to retrieve the contents of the .xml file, and then add an XML Parser node to parse the file contents and generate output schema that you can use to map the XML data in the subsequent “create” action.

XML Parser node

Tip: You can provide the XML from the Box file as a sample for generating the schema. For more information about using the XML Parser node, see Using the XML parser to parse an XML string into an XML object.

Sample XML for generating your XML  schema

Next, add a For each node and then specify the collection of items to be processed. In this case, the shiporder array of items from the XML Parser is chosen.

For each node

Using a “create” action within the For each node, you can then map to the XML content from the XML Parser so that you can create the relevant records within the required application.

Join The Discussion

Your email address will not be published. Required fields are marked *