Friday, September 26, 2008

Problems with Special Characters in XSLT

When you use Special Character like '&' and '<' during XSLT transformation, they are not rendered properly.
Eg. Expected Output:SharePoint data & SharePoint
Output:SharePoint data & SharePoint

This is the normal behaviour if you consider the XSLT specification :
"Normally, the XML output method" (the default method)" escapes '&' and '<' (and some other characters)
when outputting text nodes" (i.e. when using or nodes). Resolution:
You can disable this feature by setting the 'disable-output-escaping' attribute to 'yes' in these nodes.

Solution :
In your xsl file, replace your:

<xsl:value-of select="@href">

<xsl:value-of select="@href" disable-output-escaping="yes">