Subject: RE: apostrophe in paramter causing output problems
From: "Uronis, Jeremy" <Jeremy.Uronis@xxxxxxxxxxxxx>
Date: Wed, 15 Aug 2001 15:46:07 -0400
|
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
| Current Thread |
- apostrophe in paramter causing output problems
- Uronis, Jeremy - Wed, 15 Aug 2001 14:36:15 -0400 (EDT)
- Mike Brown - Wed, 15 Aug 2001 15:00:25 -0400 (EDT)
- <Possible follow-ups>
- Uronis, Jeremy - Wed, 15 Aug 2001 15:38:57 -0400 (EDT)
- Uronis, Jeremy - Wed, 15 Aug 2001 15:55:45 -0400 (EDT) <=
- Mike Brown - Wed, 15 Aug 2001 20:15:44 -0400 (EDT)
- Uronis, Jeremy - Wed, 15 Aug 2001 16:42:28 -0400 (EDT)
- Sunil Dua - Wed, 15 Aug 2001 17:08:36 -0400 (EDT)
- Sunil Dua - Wed, 15 Aug 2001 17:13:32 -0400 (EDT)
|
|