This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: apostrophe in paramter causing output problems


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('&#10;input: ',$myString,'&#10;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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]