|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Text() Template copy conditionally
Hi All,
In my identity template, where I need to replace "#" for downstream
processing, but I want to keep rest of the html entities which
might have "#" in them uninterrupted. Please help me , how do I
resolve this riddle?
This is my xslt for the same.
Thanks in advance for your input.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" omit-xml-declaration="yes" encoding="UTF-8" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="text()">
<xsl:choose>
<xsl:when test="text()[contains(.,'&#')]">
<xsl:copy>
<xsl:apply-templates select="."/>
</xsl:copy> </xsl:when>
<xsl:when test="text()[contains(.,'#')]">
<xsl:variable name="hash">#</xsl:variable>
<xsl:variable name="cleaned">
<xsl:call-template name="_replace_string">
<xsl:with-param name="string" select="." />
<xsl:with-param name="find" select="$hash" />
<xsl:with-param name="replace" select="'&#x23;'" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$cleaned" />
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="."/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Thanks
Senthil
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








