This topic explains how to configure and apply the XML Transformer tool, which gives you XSLT-like functionality to transform any XML.
Sections include:

Understanding XML Transformer

SOAP messages often contain a large XML payload. You may only be interested in only a small portion of that payload and wish to create regression controls using only a few elements of the response or request. Ignoring all of these elements one at a time can become very tedious. In this case, it would be more efficient to use the XML Transformer tool.

The XML Transformer gives you XSLT-like functionality to transform any XML. This is very useful if you would like to create a regression control using only a few elements of the SOAP response or request.

Configuring XML Transformer

To configure the XML Transformer, complete the following:

  1. Select the main test suite node and click the Add test or output button.
  2. Select Standard Test> XML Transformer from the Add Test wizard, and then click the Finish button. A XML Transformer node displays in the test suite.
  3. Double-click the XML Transformer node.

You can configure the following options:

Adding Regression Controls

You can add a regression control using the XPath values you extracted or altered. Right-click the SOAP Client node that contains an XML Transformer and select Create Regression Control from the shortcut menu.  A Transformed XML> Diff node appears underneath the XML Transformer node. If you select this node, you will see the XPaths you added to the Selected XPaths list in the XML Transformer tool.

Parameterizing XPaths

You can parameterize XPaths to reference test or Responder suite variables, environment variables, and data source values.  The syntax to reference variables is ${myVariableName}. The syntax to reference XML Data Bank values and Data Source Values is: ${myColumnName}. 

For example, if ${XPath Key} is a data source column name, you could use

/*[local-name(.)="bookstore" and namespace-uri(.)=""]/*[local-name(.)="book" and

namespace-uri(.)=""][child::node()[local-name(.)="title" and text()="${XPath Key}"]]

Handling Empty Elements to Maintain the Integrity of the XML Response

By default, empty elements will not be extracted.  This could impact the integrity of the XML response for use in a Writable Data Source. For instance,

would produce a Writable Data Source that looks like

ROW 1 = 5
ROW 2 = 6
If you prefer to have all nodes—including empty elements—represented in the extraction:
  1. Enable Extract empty elements as.
  2. (Optional) If you want a "placeholder" value to be added for every empty extracted element, indicate the desired placeholder string in the adjacent text field.

  3. Select one of the XPaths that specifies what to extract, then click Modify.
  4. Ensure that the Extract option is set to Content only.
  5. Delete the /text() at the end of the related XPath(s) For example, if the current XPath is 

    /*[local-name(.)="Envelope" and namespace-uri(.)=""]/.../*[local-name(.)="i" and namespace-uri(.)=""][1]/text()

    Edit it to

    /*[local-name(.)="Envelope" and namespace-uri(.)=""]/.../*[local-name(.)="i" and namespace-uri(.)=""][1]

  6. Repeat steps 3-5 for additional XPaths as needed.