Reputation: 473
I need to convert an input string -
10:05:30.00
to
10053000
that is to replace the ":" and the "." characters.
I referred to this answer - XSLT string replace
and added the replace function.
Now I can call it once like this -
<xsl:call-template name="replace-string">
<xsl:with-param name="text" select="fruits/apples"/>
<xsl:with-param name="replace" select="':'" />
<xsl:with-param name="with" select="''"/>
</xsl:call-template>
and it returns this value -
100530.00
How can I call it again where I can specify my replace string as "." so that this character is removed. Please note I have to use XSLT 1.0 so I don't have access to the replace() function in XSLT 2.0.
Upvotes: 1
Views: 308
Reputation: 117073
Why don't you do simply:
translate ($string, ':.', '')
To actually replace multiple substrings (with more than one character each), your recursive template would have to do two nested loops - with the outer loop tokenizing the search-strings
and/or the replace-strings
parameter.
Upvotes: 4