Subject: [xsl] Text() Template copy conditionally From: Senthilukvelaan <skumaravelan@xxxxxxxxxxxxxx> Date: Fri, 1 Jul 2011 12:47:58 -0700 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] XPath for parent nodes, b, Joel Dubien | Thread | Re: [xsl] Text() Template copy cond, Martin Honnen |
Re: [xsl] RE: Flat bullets to neste, Eliot Kimber | Date | [no subject], Unknown |
Month |