fn:count
In the Graphical Data Mapping editor, you can use the fn:count transform to set the value of an output element to the total number of elements in the input element.
Overview
The XPath 2.0 function fn:count((arg1, arg2,arg3, ...))
takes a list of elements
and returns the total number of elements.
The fn:count transform is the representation of the fn:count XPath function in the Graphical Data Mapping editor.
You can have any number of inputs to the fn:count transform. These inputs can be used to define the arguments of the fn:count function.
Inputs to the transform
You can connect one or more inputs to the fn:count transform. These inputs are used to define the argument of the fn:count function.
In the following figure, there are 4 inputs to the fn:count transform.
<?xml version="1.0" encoding="UTF-8"?>
<NewElement>
<A>10</A>
<C>100</C>
<C>1000</C>
<C>10000</C>
<D>1000</D>
<E>112</E>
</NewElement>
Arguments of the XPath function
You define the argument to the fn:count function in the General tab of the fn:count transform properties view.
You can define a literal expression, a constant, an input element, or a custom XPath expression as the argument.
In the following figure, there are 4 inputs to the fn:count transform. A is only considered if the string length is greater than 4. A literal expression has been added as an additional element in the argument.
<?xml version="1.0" encoding="UTF-8"?>
<NewElement>
<A>10</A>
<C>100</C>
<C>1000</C>
<C>10000</C>
<D>1000</D>
<E>112</E>
</NewElement>
Cardinality
The Cardinality property determines the elements (also known as indexes) in each repeating input element that is processed by the fn:count transform.
You can configure the Input array indexes section to select specific instances of the input array. For more information, see Selecting the indexes of input array elements.
Define when the transform is applied at run time
You can use any of the input elements to the fn:count 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. You define this expression in the Condition tab of the tranform properties.
For more information, see Configuring the properties of a transform.