Description
The functx:replace-multi function performs multiple calls to the fn:replace function. It takes as arguments a sequence of strings or patterns to change from, and sequence of strings to change to. It iterates through the sequences, calling the built-in fn:replace function for each pair in order.
Arguments and Return TypeName | Type | Description |
$arg |
xs:string? |
the string to manipulate |
$changeFrom |
xs:string* |
the sequence of strings or patterns to change from |
$changeTo |
xs:string* |
the sequence of strings to change to |
return value |
xs:string? |
XSLT Function DeclarationSee XQuery definition. | <xsl:function name="functx:replace-multi" as="xs:string?"
xmlns:functx="http://www.functx.com">
<xsl:param name="arg" as="xs:string?"/>
<xsl:param name="changeFrom" as="xs:string*"/>
<xsl:param name="changeTo" as="xs:string*"/>
<xsl:sequence select="
if (count($changeFrom) > 0)
then functx:replace-multi(
replace($arg, $changeFrom[1],
functx:if-absent($changeTo[1],'')),
$changeFrom[position() > 1],
$changeTo[position() > 1])
else $arg
"/>
</xsl:function>
|
Examples<xsl:variable name="fr" select="('[a-c]', 'def', '\d+')"/>
| <xsl:variable name="to" select="('x', 'y', '0')"/>
|
XPath Example | Results |
---|
functx:replace-multi('abcdef123',$fr,$to) |
xxxy0 |
Depends Onfunctx:if-absent | The first argument if it is not empty, otherwise the second argument |
See AlsoHistory |
Recommended Reading:
|