How do I string manipulation on the output of <xsl:apply-templates>
?
I need to escape quotes etc as it's finally being passed to a JavaScript variable.
How do I string manipulation on the output of <xsl:apply-templates>
?
I need to escape quotes etc as it's finally being passed to a JavaScript variable.
Capture in a variable, then manipulate the value to create the output:
<xsl:variable name='temp'>
<xsl:apply-templates ...>
</xsl:variable>
<xsl:value-of select='expression involving $temp' />
The nice and clean approach would be to change your XSLT so that it's output does not need any additional manipulation.
If your call to <xsl:apply-templates>
produces a string that must be manipulated for some reason, you would need to capture it in a variable first:
<xsl:variable name="temp">
<xsl:apply-templates />
</xsl:variable>
<xsl:variable name="temp-manipulated">
<xsl:call-template name="do-some-string-mainpulation">
<xsl:with-param name="string" select="$temp" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$temp-manipulated" />
Alternatively, you can integrate the <xsl:apply-templates>
into the <xsl:with-param>
, wich would spare you one step:
<xsl:variable name="temp">
<xsl:call-template name="do-some-string-mainpulation">
<xsl:with-param name="string">
<xsl:apply-templates />
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$temp" />