Checking whether the value of an input element exists, or is null

You can use the fn:exists XPath function, and the fn:nilled XPath function to define conditional expressions that determine whether an input element is present, or is null.

About this task

You can define conditional expressions in a transform to determine whether the transform should be applied or not in your message map.

For example, you might decide not to apply a transform if the input value is null.

You can use the following XPath functions to define conditional expressions in a transform:
  • Use the fn:nilled XPath function to test whether the value of an input element has the xsi:nil attribute set.
  • Use the fn:exists XPath function to test whether the value of an input element is present.
    Note: An XML element that has the xsi:nil attribute set is considered to be present.

Procedure

Take the following steps to define a conditional expression in a Move transform that determines whether the transform is applied or not. The transform applies if the element exists, and is not null.

  1. Create a Move transform between an input element and an output element.
  2. In the Properties view, under Condition, enter an XPath expression to define the conditional expression that must evaluate to true for the transform to be applied.
    fn:exists($BookName) and (fn:nilled( $BookName) = false)