fn:concat
In the Graphical Data Mapping editor, you can use the fn:concat transform to create a string output element that is the result of concatenating simple input elements.
Overview
The XPath 2.0 function fn:concat(arg1, arg2, ,,,)
takes two or more arguments,
converts them to their string representation, and concatenates them, returning a single string.
The fn:concat transform is the representation of the fn:concat XPath function in the Graphical Data Mapping editor.
You can have any number of inputs to the fn:concat transform. These inputs are used to define the arguments of the fn:concat function.
For more information about XPath, see XPath tutorial or W3C XML Path Language (XPath) 2.0.
When to use the fn:concat transform
You can use fn:concat to concatenate input elements.
- You can use the first argument as the prefix.
- You can use the last argument as the suffix.
- You can insert a delimiter as an argument between any two arguments you want to delimit.
Inputs to the transform
You can connect simple elements to the fn:concat transform.
Simple input elements that are not of type xs:string will be cast to xs:string.
The following figure shows two inputs connected to the fn:concat transform:
- If the input XML has no more than one instance of the repeatable input, the fn:concat transform produces the expected result at run time.
- If the input XML has more than one instance of the repeatable input, the fn:concat transform results in a run time exception.
Arguments of the XPath function
The fn:concat function has two or more non-repeating arguments.
You define the number and the order of the arguments to the fn:concat function in the General tab of the fn:concat transform properties view.
- You can add a literal value entered in single quotes.
- You can add a Custom XPath expression.
In the following figure, the fn:concat transform has two inputs. Each input is used as an argument of the fn:concat function:
In the following figure, the fn:concat transform has three inputs, whilst the fn:concat function only requires two arguments. Two of the inputs are used to define one of the arguments of the fn:concat transform:
Define a conditional expression
You can use any of the input elements to the fn:concat transform to define a conditional expression that defines the condition under which the transform is applied. If the condition evaluates to true, the transform is applied.
For more information, see Configuring the properties of a transform.
Example
This example shows how to use the fn:concat transform to concatenate multiple input elements and set the value of a string element by using the fn:concat function.
The arguments to the XPath function include a prefix, two elements, and one suffix. One of the arguments is set by an XPath function base on calculations from data from two inputs. One of the arguments is set with data from an input. The prefix and the suffix are literals.
<NewElement>
<A>My FieldA</A>
<B>B1</B>
<C>Field_1</C>
<D>4</D>
<E>FIELD_E</E>
</NewElement>
<NewElement1>
<a>MyPrefixtrueFIELD_EMySuffix</a>
</NewElement1>