By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,403 Members | 880 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,403 IT Pros & Developers. It's quick & easy.

help: xslt2 replace / with \

P: n/a
Can someone help me by providing an example of how to replace / with \
in a string in xslt2.

The characters / and \ seem to cause me grief ...

I am trying the below code currently ...

Any help is appreciated ..

Jim

....
....

<xsl:call-template name="replace-string">
<xsl:with-param name="text" select="$buildDir">
</xsl:with-param>
<xsl:with-param name="replace" select="/">
</xsl:with-param>
<xsl:with-param name="with" select="\">
</xsl:with-param>
</xsl:call-template>

....
....

<xsl:template name="replace-string">
<xsl:param name="text"/>
<xsl:param name="replace"/>
<xsl:param name="with"/>
<xsl:choose>
<xsl:when test="contains($text,$replace)">
<xsl:value-of select="substring-before($text,$replace)"/>
<xsl:value-of select="$with"/>
<xsl:call-template name="replace-string">
<xsl:with-param name="text" select="substring-after($text,$replace)"/>
<xsl:with-param name="replace" select="$replace"/>
<xsl:with-param name="with" select="$with"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$replace"/>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

....
....
Apr 26 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Random Task wrote:
Can someone help me by providing an example of how to replace / with \
in a string in xslt2.

The characters / and \ seem to cause me grief ...


<xsl:call-template name="replace-string">
<xsl:with-param name="text" select="$buildDir" />
<xsl:with-param name="replace" select="'/'" />
<xsl:with-param name="with" select="'\'" />
</xsl:call-template>

<xsl:template name="replace-string">
<xsl:param name="text" />
<xsl:param name="replace" />
<xsl:param name="with" />
<xsl:value-of select="translate($text, $replace, $with)" />
</xsl:template>
JW
Apr 26 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.