Keep   and other special characters in XSLT output with apply-templates

martincho

New Member
I'm using XSLT to extract some HTML content with special characters (like \[code\]&nbsp;\[/code\]) from an XML file. The content is stored in \[code\]<content>\[/code\] nodes. I have defined most special characters like this: \[code\]<!ENTITY nbsp " ">\[/code\], so this expression works perfectly fine:\[code\]<xsl:copy-of select="content" disable-output-escaping="yes"/>\[/code\]Now, I want to add \[code\]target="_blank"\[/code\] to every link found within that content. This is the solution I came up with:\[code\]<xsl:template match="a" mode="html"> <a> <xsl:attribute name="href"><xsl:value-of select="@*"/></xsl:attribute> <xsl:attribute name="target">_blank</xsl:attribute> <xsl:apply-templates select="text()|* "/> </a></xsl:template>\[/code\]And instead of the "copy-of" element I use this:\[code\]<xsl:apply-templates select="content" mode="html"/>\[/code\]Now all those special characters (and nbsp too) disappeared from the output. How do I keep them? Seems like \[code\]disable-output-escaping="yes"\[/code\] doesn't help here. Thanks!
 
Back
Top