xslt - 浏览器不受支持的 Tridion 2011 SP1 富文本 XSLT 中的命名空间问题

标签 xslt tridion tridion-2011

我在模式(Tridion 2011 SP1)中有一个富文本字段,附加了一个基本的 XSLT 过滤器(默认 XSLT 或自定义过滤器,对于这个问题无关紧要)。

在 IE9 中,当我基于该架构创建组件时,源选项卡中的 XHTML 呈现良好,没有任何命名空间,例如:

<p>a paragraph</p>
<p>
    <a href="http://www.sdltridion.com">a link</a>
</p>

我能够保存组件。

但是在 Firefox(16.0.2,不支持)中,在 Source 选项卡中呈现了一个命名空间:
<p xmlns="http://www.w3.org/1999/XSL/Transform">a paragraph</p>
<p xmlns="http://www.w3.org/1999/XSL/Transform">
    <a href="http://www.sdltridion.com">a link</a>
</p>

这会导致以下 XML 验证错误:

The element 'Paragraph' in namespace 'http://www.yme.com/GeneralContent' has invalid child element 'p' in namespace 'http://www.w3.org/1999/XSL/Transform'. List of possible elements expected: any element in namespace 'http://www.w3.org/1999/xhtml'..



现在我知道它是一个不受支持的 Firefox 版本,但是这个命名空间来自哪里? Richtext XSLT 中定义的命名空间是 http://www.w3.org/1999/XSL/Transform ...

有没有人知道可能的解决方法?

这是过滤 XSLT,但正如我已经说过的,默认 XSLT 也会发生这种情况:
<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform">
    <output omit-xml-declaration="yes" method="xml" cdata-section-elements="script"></output>
    <template match="/ | node() | @*">
        <copy>
            <apply-templates select="node() | @*"></apply-templates>
        </copy>
    </template>
    <template match="*[(self::br or self::p or self::div) and normalize-space(translate(., &apos; &apos;, &apos;&apos;)) = &apos;&apos; and not(@*)     and      not(processing-instruction()) and not(comment()) and not(*[not(self::br) or @* or * or node()]) and not(following::node()[not((self::text() or self::br or self::p or self::div) and normalize-space(translate(., &apos; &apos;, &apos;&apos;)) = &apos;&apos;        and         not(@*) and not(processing-instruction()) and not(comment())        and         not(*[not(self::br) or @* or * or node()]))])]">
    </template>
    <template match="br[parent::div and not(preceding-sibling::node()) and not(following-sibling::node())]">
        <text></text>
    </template>
    <template match="table|td|tr|th|tbody|p|div|a">
        <element name="{name()}">
            <choose>
                <when test="name() =&apos;img&apos;">
                    <for-each select="@*">
                        <attribute name="{name()}">
                            <value-of select="."></value-of>
                        </attribute>
                    </for-each>
                </when>
                <otherwise>
                    <for-each select="@*">
                        <choose>
                            <when test="name() =&apos;border&apos;"></when>
                            <when test="name() =&apos;cellpadding&apos;"></when>
                            <when test="name() =&apos;cellspacing&apos;"></when>
                            <when test="name() =&apos;bgcolor&apos;"></when>
                            <when test="name() =&apos;bordercolor&apos;"></when>
                            <when test="name() =&apos;width&apos;"></when>
                            <when test="name() =&apos;height&apos;"></when>
                            <when test="name() =&apos;bordercolor&apos;"></when>
                            <when test="name() =&apos;span&apos;"></when>
                            <when test="name() =&apos;style&apos;"></when>
                            <when test="name() =&apos;class&apos;">
                                <choose>
                                    <when test=". =&apos;MsoNormal&apos;"></when>
                                    <otherwise>
                                        <attribute name="{name()}">
                                            <value-of select="."></value-of>
                                        </attribute>
                                    </otherwise>
                                </choose>
                            </when>
                            <otherwise>
                                <attribute name="{name()}">
                                    <value-of select="."></value-of>
                                </attribute>
                            </otherwise>
                        </choose>
                    </for-each>
                </otherwise>
            </choose>
            <apply-templates></apply-templates>
        </element>
    </template>
    <template match="h1">
        <element name="h2">
            <apply-templates></apply-templates>
        </element>
    </template>
    <template match="td/p">
        <apply-templates></apply-templates>
    </template>
    <template match="li/p">
        <apply-templates></apply-templates>
    </template>
    <template match="link|script|font|iframe|ilayer|layer|span|small">
        <apply-templates></apply-templates>
    </template>
</stylesheet>

最佳答案

我相信这个问题与这篇文章有关

Tridion 2011 - Filtering XSLT on Formatting Feature window

似乎迁移过程(或者可能是奇怪的 GUI 行为)正在改变过滤 XSLT,并且似乎影响了 RTF 字段的行为。基本上命名空间和命名空间前缀在 XSLT 中的使用方式似乎已经改变。典型的 XSLT 使用 xsl命名空间前缀,而您的新 XSLT 似乎排除了前缀并使用默认命名空间。

我认为这是一个错误,应该提交给支持,但相关帖子中介绍了解决方法。

关于xslt - 浏览器不受支持的 Tridion 2011 SP1 富文本 XSLT 中的命名空间问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13362450/

相关文章:

xslt - XSL条件总计

tridion - 多媒体预览未更新?

tridion - 直接在服务器下添加 .css 和 JavaScript 文件并在 TBB 中访问它们

asp.net - 如何在命名空间中选择 xml 元素?

xml - XSLT 在网络浏览器中不工作

xml - XSLT 模板的执行顺序

tridion - 使用 Visual Studio 中的构建后事件在 Tridion 中上传 DLL 时出错

javascript - Tridion 2011 SP1 : Tridion GUI Javascript error with Translation Manager and Powertools 2011 installed

tridion - 上传图片超时

Tridion 和 REL : Updating page filename within the page's PublishedUrl property