My problem is how to add disable-output-escaping="yes" to the xsl document so that it will be applied in all templates.
This is a feature of XSLT 2.0, where disable-output-escaping
has been considered deprecated and replaced by xsl:character-maps
. These character maps can be applied to the whole output.
Note that <![CDATA[AT&T]]>
is the same as AT&T
. Any XML having AT&T
will be displayed in a client as AT&T
, because it is merely a way of escaping the &
. Forcing the &
to not be escaped makes the resulting XML invalid XML. If HTML is your output, then in some cases this kind of escaping is required (i.e. in script
elements).
A workaround you can use in XSLT 1.0 is as follows. Assuming your entry point is where you start at the root node:
<xsl:template match="/">
<!-- your code here -->
</xsl:template>
Replace that with:
<xsl:template match="/">
<xsl:variable name="pre-process">
<!-- your code here -->
<xsl:variable>
<xsl:apply-templates select="exslt:node-set($pre-process)" mode="escape"/>
</xsl:template>
<xsl:template match="@* | *" mode="escape">
<xsl:copy>
<xsl:apply-templates select="node()" mode="escape"/>
</xsl:copy>
</xsl:template>
<xsl:template match="text()" mode="escape">
<xsl:value-of select="." disable-output-escaping="yes" />
</xsl:template>
The above code simply re-processes everything and specificially processes text nodes to be escaped (the only nodes to matter when it comes down to escaping). The code depends on the availability of the extension function exslt:node-set, but just about every XSLT 1.0 processor supports it.
A few comments on the code provided in the link:
<xsl:if test="following-sibling::*">
<xsl:text></xsl:text>
</xsl:if>
This has no effect.
<xsl:sort>
<xsl:attribute name="select"><xsl:value-of select="meta_data//bindto"/></xsl:attribute>
<xsl:attribute name="data-type"><xsl:value-of select="meta_data//sortby_type"/></xsl:attribute>
<xsl:attribute name="order"><xsl:value-of select="meta_data//direction"/></xsl:attribute>
</xsl:sort>
This has no effect (sorting attributes is meaningless, as attributes are always output in any order preferred by the processor).
<xsl:text><xsl:value-of select="display_precision"/></xsl:text>
This is illegal, if you still have this, you will not be able to run your stylesheet.