且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用XSLT解析XML字符串

更新时间:2022-03-21 18:51:44

<xsl:value-of select="TextBlock" disable-output-escaping="yes"/>

,结果为:

<h1>This is a header.</h1>
<p>This is a paragraph.</p>

Firefox有一个相应的错误: https://bugzilla.mozilla.org/show_bug.cgi?id=98168 ,其中包含很多评论,是一本有趣的文章。

Firefox has a corresponding bug: https://bugzilla.mozilla.org/show_bug.cgi?id=98168, which contains a lot of comments and is an interesting reading.

我正在寻找修复程序。

编辑

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:import href="disable-output-escaping.xsl"/> 
    <!-- https://bug98168.bugzilla.mozilla.org/attachment.cgi?id=434081 -->
    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>

    <xsl:template match="/TextBlock">
        <xsl:copy>
            <xsl:call-template name="disable-output-escaping"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>

通过Firebug检查时,结果看起来正确:

When inspecting via Firebug, the result looks correct:

<textblock>
    <h1>This is a header.</h1>
    <p>This is a paragraph.</p>
</textblock>