Table of Contents
This article assumes you are conversant with using the TaskCentre DTC (Data Transformation Component) to transform the structure and content of XML data used within TaskCentre.
If you are viewing this knowledge base article then you wish to process XML that contains nodes or elements with attributes and the structure will resemble something similar to figure 1:
Given the XML structure shown in figure 1 above, the task browser window should display a recordset containing six items, three items relating to the three different elements and the data they contain and a further three items relating to the attributes within each element.
However, we can see in figure 2 that the XML Attributes do not register in the Task Browser Window only the data elements are exposed when we view the resultant record set fields.
In order to overcome this we use the DTC within the Web Service Connector tool (WSCT). Instructions follow.
Create a New Web Service Configuration in the Global Configuration of the Web Service Connector Tool, selecting the last radio button as shown in figure 3 below. We have called this ProcessAttributes.
Create a new Multi Message Operation (MMO), we will not need any Single Message Operations as we are only going to be using the Data Transformation Component (DTC) to transform the data and not communicating with any Web Service. In this example we have called the new operation ‘ExtractAttributes’. See figure 4.
Double click on the Input section to begin configuring an Input Data Structure. Here we will create a very similar data structure to the source data but with additional Elements. These additional elements will be used to hold the data contained within the source XML’s attributes. Once you have created the data structure, export it and save it somewhere accessible before clicking OK. We can reuse this structure for the output XML.
The screenshot figure 5 shows the schema structure used to define both the input and output schema for this operation.
Now double click on the Output section to begin configuring the Output data structure. Once the screen has opened, click on the import button and select the file we created in the previous step. Once imported, move over to the mappings tab and begin mapping the Input data to the Output data.
The following screenshot figure 6 demonstrates what the mapping tab should look like:
We now return to the Task created earlier and insert a new Web Service Connector Step, selecting the new Web Service Configuration and new MMO.The step should be configured so that it uses the Document Source from the XML Import Tool. Figure 7 refers.
The mapping screen will now show the XML from the source document on the left hand side and the input data structure we created on the right hand side. Notice how the XML on the left hand side contains both elements and attributes now (represented by the ‘@’) sign:
Mapping the elements and the attributes into our input structure effectively extracts the attribute data successfully and presents it in a format our XML to Recordset tool can understand.
Remember to add a simple loop to iterate through the structure if applicable.
See our e-learning material if you need help in setting up loops in the DTC: Transform Functions – Simple Looping
Now change the Convert XML to Recordset tool’s document source to consume the Web Service Connector tool’s Output XML and then open the task browser. Navigate to the Convert XML to Recordset tool’s Recordset and notice how we now see the Output XML Structure we created in the MMO. The Web Service Connector tool step has now extracted the data from the attributes and placed it into the new elements we created.