Introduction
This article describes how to process XML attributes in a source document so that they can be processed by other BPA Platform tools.
Why Is This Needed?
Tools that can consume and process XML are able to recognise XML attributes. However, where the data is required by a recordset-only consuming BPA Platform tool, a conversion must take place first. Available conversion tools do not recognise XML attributes so such XML structures must be flattened first.
Example XML Structure
Let's take the following XML:
<?xml version='1.0' encoding='UTF-8'?> <dataset> <company id="1"> <name>Corkery, Graham and Kessler</name> <contact>Joshuah Gregorin</contact> <address>7 American Ash Court</address> </company> <company id="2"> <name>Parisian LLC</name> <contact>Natka Mochar</contact> <address>98298 Kim Place</address> </company> <company id="3"> <name>Spinka, Moen and Jakubowski</name> <contact>
and so on.
When you import this file into your task, the structure is recognised correctly — Import XML Document
The Import XML Document tool imports an XML document to be used and processed by other task steps. To validate the XML documents at runtime, you can either import an XML schema file (XSD), infer from an existing XML document, or manually construct the XSD. tool > Main tab > OutputXML tab. However, when you use the Convert XML to Recordset
The Convert XML to Recordset tool is used to convert XML data into a flat-format BPA Platform recordset, allowing the data to be used by recordset-only consuming tools. This could then be used to power alerts via fax, email, or SMS, create reports, power a workflow, perform FTP transfer, and so on. tool, the created recordset looks like:
The attributes are completely ignored for the output.
Adding Attributes to the XML Output
Using the XML example above, we use the Transform Data
Transform Data is a Format tool that enables a new structure to be created from an existing XML or recordset data source. The output generated by this tool is ready for use in a destination system which consumes or requires XML. tool to create a flat XML structure where the attribute is converted to an additional XML element. This can then be converted to a recordset structure later, if required, by the Convert XML to Recordset tool.
Do the following:
- Import the XML file to the task using the Import XML Document tool.
- Add a Transform Data step to the task and consume the output from the previous Import XML Document step.
- In the General tab of the Transform Data step, enable Use a recordset or XML source from another step.
- From the Input Source drop-down, select OutputXML from Import XML Document. Note that you may see a different step name if you changed the default step name.
- Go to the Main tab.
- Click Add Node and change the Name to the top-level element — in this example, we are using
company. - Use Add Element to add the other XML elements.
- Add another new element for the attribute — in this example, we have
id. - Use the up and down arrows to move the new attribute / element to the required location in the output XML structure.

- Go to the Mapping tab and map the original elements to new (click and drag one element to the other):

You'll notice in the example above that the parent element
companyis also mapped. This forces the Transform Data tool to "step through" the input XML document to ensure that for everycompanyrecord found, a mapped record is created in the output XML. Without this, only the first record encountered is outputted. When creating the mapping, a Simple function is automatically created — no further configuration is required for this. - Click OK to save the step.
- You can now add a Convert XML to Recordset step to create the correct recordset then continue with the task.
The recordset should now look like:
The recordset can now be successfully consumed and processed by other BPA Platform tools. Note how the column names are also prefixed with the parent XML node name too.
Article originally published 03 December 2015 — Article updated 02 March 2020