This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: apostrophe in paramter causing output problems
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] apostrophe in paramter causing output problems
- From: "Uronis, Jeremy" <Jeremy dot Uronis at usa dot xerox dot com>
- Date: Wed, 15 Aug 2001 15:46:07 -0400
- Reply-To: xsl-list at lists dot mulberrytech dot com
actually im confused. how does myString
get set to the new value?
<xsl:template match="/">
<!-- example showing replacement of '%20' with a single space -->
<xsl:variable name="myString" select="'This%20is%20a%20Test'"/>
<xsl:variable name="myNewString">
<!-- go create the result tree fragment with the replacement
-->
<xsl:call-template name="SubstringReplace">
<xsl:with-param name="stringIn" select="$myString"/>
<xsl:with-param name="substringIn" select="'%20'"/>
<xsl:with-param name="substringOut" select="' '"/>
</xsl:call-template>
</xsl:variable>
<!--
show the new string. concat() will treat the result tree
fragment as if it were a string returned by the string() function.
-->
<xsl:value-of select="concat(' input: ',$myString,' output:
',$myNewString)"/>
</xsl:template>
<!-- here is the template that does the replacement -->
<xsl:template name="SubstringReplace">
<xsl:param name="stringIn"/>
<xsl:param name="substringIn"/>
<xsl:param name="substringOut"/>
<xsl:choose>
<xsl:when test="contains($stringIn,$substringIn)">
<xsl:value-of
select="concat(substring-before($stringIn,$substringIn),$substringOut)"/>
<xsl:call-template name="SubstringReplace">
<xsl:with-param name="stringIn"
select="substring-after($stringIn,$substringIn)"/>
<xsl:with-param name="substringIn"
select="$substringIn"/>
<xsl:with-param name="substringOut"
select="$substringOut"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$stringIn"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list