.. _functx_replace-element-values:
=============================
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.
.. list-table::
:widths: 40 60
:header-rows: 1
* - **Parameters**
- **Description**
* - elements:element()
- the elements whose content you wish to replace
* - values:string()
- the replacement values
Examples
~~~~~~~~
.. list-table::
:widths: 50 50
:header-rows: 1
* - **XPath**
- **Results**
* - functx:replace-element-values( $in-xml/price, for $p in $in-xml/price return $p * 2)
- 24 40 10
* - for $p in $in-xml/price return functx:replace-element-values( $p,concat($p,'.0'))
- 12.0 20.0 5.0