Mapping with Conditions Using Test Expressions

By defining a Test expression in the Properties View, you can create maps in which the inclusion of elements or attributes in the target schema can be conditionally based on elements or attributes in the source schema.

A test defines the conditions under which the link should run. If the test fails, the target element is not created. This is different from using the Choose function in a Transformation Rule, which always creates the target element, but controls the value that goes into the element.

To map with conditions using Test Expressions:

  1. To open the Properties View, select Window>Show View>Properties from the menu bar.

  2. In the Map Editor, click the map link for which you want to define conditions.
    The Properties View displays the properties for the selected map.

  3. In Properties, select one of the following Mapping Modes from the drop-down list:

for-each

value-of

copy-of

for-each-value-of

  1. To output a value inside a CDATA Section, set the Output as CDATA property to Yes. If your map requires that a source element value be output in an embedded XML CDATA Section, set the Output as CDATA property to Yes.

  2. Define the Test Expression Value.
    In the Link section of the Properties View, enter a Test Expression value.
    For example:  sourceElementName='500'

  1. To save your changes, select File>Save mapName.map from the menu bar.
    When you save your map, the XSLT required to transform the source to target document is automatically generated.

  2. View the Generated XSLT.

  3. Test your map.