CDATA标签被包裹起来并被注释

时间:2018-09-24 14:10:23

标签: xslt xhtml

我正在将XHTML转换为另一个XHTML(用于本地化),我们可以使用的工具是XSLT,这是一个限制。现在,当我尝试按测试原样复制整个代码时,原始XHTML的CDATA值将丢失。我在标签cdata-section-elements =“ script”下面使用了它,但是它注释了整个CDATA,导致原始XHTML的格式丢失

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">

<xsl:output method="html" cdata-section-elements="script"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" 
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
<xsl:template match="div[@id='HEADER']">
    <div id="HEADER">
        <p>This is the <em>improved</em> header.</p>
    </div>

</xsl:template>
<xsl:template match="script|style">
    <xsl:copy>
        <xsl:apply-templates select="@*"/>
        <xsl:value-of disable-output-escaping="yes" select="concat('//&lt;![CDATA[&#xA;',text(),'&#xA;//]]&gt;')" />
    </xsl:copy>
</xsl:template>

<xsl:template match="*|@*" >
    <xsl:copy>
        <xsl:apply-templates select="@*"/>
        <xsl:apply-templates/>
    </xsl:copy>
</xsl:template>
</xsl:stylesheet>

0 个答案:

没有答案
相关问题