XSLT in component gets (un)encoded
Asked Answered
L

3

11

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>
Lazo answered 30/1, 2013 at 12:52 Comment(7)
Please show your the complete content node of your Component XML, and the template code you are using to output the content/xslt. It might be useful to specify if your XSLT code is in a plain text or RTF field also.Sejant
Updated the question with more complete code and yes, it is in a plain textfieldLazo
Can I safely assume you are using the XSLT mediator?Sejant
Wait a sec. That XSLT is for a page template. Can u share your CT that renders the component presentation?Sejant
Watch and learn from the master! @ChrisSummers made me fix the error remotely via StackOverflow! The HTMLEncode of course should not be in there for this XSLT output!Lazo
What do I do now, answer my own question? But, I should give the kudos to @ChrisSummersLazo
answer your own question - take the points - Glad you figured it outSejant
L
7

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>
Lazo answered 30/1, 2013 at 14:23 Comment(1)
I can't... You have to wait two days to accept your own answer :-(Lazo
S
3

How are you outputting the XSLT, with a template I assume? Can you post your template?

You probably need to use a "disable-output-escaping='yes'" attribute if you are using an XSLT template, see: http://www.w3schools.com/xsl/el_value-of.asp

Sejant answered 30/1, 2013 at 13:12 Comment(0)
F
2

I faced the similar issue earlier, for resolving this, i have to used another C# TBB, which removed the current value again to original value.

Ferebee answered 30/1, 2013 at 13:11 Comment(1)
Thanks for your answer, It ended up being a HTMLDecode method, which ruined it.Lazo

© 2022 - 2024 — McMap. All rights reserved.