tridiontridion2009

XSLT in component gets (un)encoded


Really simple question, but I can't seem to get it working right.

I have a component in which there is some XSLT (for navigation). It gets published using the XSLT Mediator via an XSLT TBB.

Upon publishing the &lt; gets changed into <, and breaks the xslt...

The Component content (Plain textfield)

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcm="http://www.tridion.com/ContentManager/5.0" exclude-result-prefixes="tcm xsl xs xlink tridion">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes" />
    <xsl:template match="/">
        <xsl:apply-templates select="/node/node[@type='folder')='0' and position() &lt; 3]">
           <xsl:sort select="sortnum"/>
        </xsl:apply-templates>

        <xsl:template match="node">
            <xsl:text>Lorem Ipsum</xsl:text>
        </xsl:template>
</xsl:stylesheet>

The XLT CT TBB outputting this component:

<xsl:stylesheet version="1.0" xmlns:tcm="http://www.tridion.com/ContentManager/5.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tridion="http://www.tridion.com/ContentDelivery/5.3/TCDL" xmlns:xlink="http://www.w3.org/1999/xlink"  xmlns:helper="http://www.tridion.com/xslthelper" xmlns:systeemcode="http://www.indivirtual.nl/SysteemCode" xmlns:xhtml="http://www.w3.org/1999/xhtml" exclude-result-prefixes="tcm xsl tridion xlink systeemcode xslthelper helper xhtml">
    <xsl:output method="text" omit-xml-declaration="yes" indent="yes" encoding="utf-8" standalone="no"/>
    <xsl:variable name="content" select="/tcm:Component/tcm:Data/tcm:Content/systeemcode:SysteemCode"/>
    <xsl:template match="/">
        <xsl:value-of disable-output-escaping="yes" select="helper:HtmlDecode($content/systeemcode:code)"/>
    </xsl:template>
</xsl:stylesheet>   

The XSLT Page TBB outputting the CP:

<xsl:stylesheet version="1.0" xmlns:helper="http://www.tridion.com/xslthelper" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tcm="http://www.tridion.com/ContentManager/5.0" xmlns:xlink="http://www.w3.org/1999/xlink">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
    <xsl:template match="tcm:ComponentPresentation">
        <xsl:value-of select="helper:GetRenderedComponent(./tcm:Component/@xlink:href, ./tcm:ComponentTemplate/@xlink:href)" disable-output-escaping="yes"/>
    </xsl:template>
</xsl:stylesheet>

Solution

  • The problem was found in the CT TBB (Thanks to @ChrisSummers).

    The XSLT CT TBB outputting this component had a reference to an XSLT mediator HTMLEncoding helper:HtmlDecode() method, which is fine for normal text, but not for XSLT. I removed it and issue solved:

    <xsl:stylesheet version="1.0" xmlns:tcm="http://www.tridion.com/ContentManager/5.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tridion="http://www.tridion.com/ContentDelivery/5.3/TCDL" xmlns:xlink="http://www.w3.org/1999/xlink"  xmlns:helper="http://www.tridion.com/xslthelper" xmlns:systeemcode="http://www.indivirtual.nl/SysteemCode" xmlns:xhtml="http://www.w3.org/1999/xhtml" exclude-result-prefixes="tcm xsl tridion xlink systeemcode xslthelper helper xhtml">
        <xsl:output method="text" omit-xml-declaration="yes" indent="yes" encoding="utf-8" standalone="no"/>
        <xsl:variable name="content" select="/tcm:Component/tcm:Data/tcm:Content/systeemcode:SysteemCode"/>
        <xsl:template match="/">
            <xsl:value-of disable-output-escaping="yes" select="$content/systeemcode:code"/>
        </xsl:template>
    </xsl:stylesheet>