functx:replace-element-values
Updates the content of one or more elements
Description
The functx:replace-element-values function takes a sequence of elements and updates their values with the values specified in $values. It keeps all the original attributes of the elements in tact. This is useful if you would like to perform an operation on a sequence of elements, for example, doubling them or taking a substring, without eliminating the elements themselves. The two argument sequences are positionally related; i.e. the first element in $elements takes on the first value in $values, the second element takes on the second value, etc.
Parameters |
Description |
---|---|
elements:element() |
the elements whose content you wish to replace |
values:string() |
the replacement values |
Examples
XPath |
Results |
---|---|
functx:replace-element-values( $in-xml/price, for $p in $in-xml/price return $p * 2) |
<price num=”1”>24</price> <price num=”2”>40</price> <price num=”3”>10</price> |
for $p in $in-xml/price return functx:replace-element-values( $p,concat($p,’.0’)) |
<price num=”1”>12.0</price> <price num=”2”>20.0</price> <price num=”3”>5.0</price> |