问题 组件中的XSLT得到(未)编码


真的很简单的问题,但我似乎无法让它正常工作。

我有一个组件,其中有一些XSLT(用于导航)。它通过XSLT TBB使用XSLT Mediator发布。

在发布&lt;变为<,并打破xslt ...

组件内容(纯文本字段)

<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>

XLT CT TBB输出该组件:

<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>   

输出CP的XSLT页面TBB:

<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>

9643
2018-01-30 12:52


起源

请显示组件XML的完整内容节点,以及用于输出content / xslt的模板代码。指定XSLT代码是否也在纯文本或RTF字段中可能很有用。 - Chris Summers
使用更完整的代码更新了问题,是的,它是在纯文本字段中 - Hendrik Beenker
我可以安全地假设您正在使用XSLT介体吗? - Chris Summers
等一下。 XSLT用于页面模板。你可以分享你的CT来呈现组件吗? - Chris Summers
观看并向大师学习! @ChrisSummers让我通过StackOverflow远程修复错误! HTMLEncode当然不应该出现在这个XSLT输出中! - Hendrik Beenker


答案:


问题出现在CT TBB中(感谢@ChrisSummers)。

输出此组件的XSLT CT TBB引用了XSLT介体HTMLEncoding 助手:HtmlDecode() 方法,适用于普通文本,但不适用于XSLT。我删除它并解决问题:

<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>

7
2018-01-30 14:23



是时候接受你自己的答案了@Hendrik - Chris Summers
我不能......你必须等两天才能接受你自己的答案:-( - Hendrik Beenker


您如何使用我假设的模板输出XSLT?你可以发布你的模板吗?

如果您使用的是XSLT模板,则可能需要使用“disable-output-escaping ='yes'”属性,请参阅: http://www.w3schools.com/xsl/el_value-of.asp


3
2018-01-30 13:12





我之前遇到过类似的问题,为了解决这个问题,我必须使用另一个C#TBB,它将当前值再次移除到原始值。


2
2018-01-30 13:11



关心分享TBB的代码? - Frank van Puffelen
感谢您的回答,它最终成为HTMLDecode方法,破坏了它。 - Hendrik Beenker