这个问题以前问过,但没说清楚,这次再问,以实例来问吧,
xml 文件:
1<article>
2<content><![CDATA[ <font size=7>hello, world.</fontsize>]]></content>
3</article>
======================================================
xsl 文件:
1<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl">
2<xsl:template match="/">
3<html><body>
4<xsl:value-of select="article/Content"></xsl:value-of>
5</body></html>
6</xsl:template>
7</xsl:stylesheet>
======================================================
转换后得到的 html 代码为:
1<html><body>
2<font size=7>hello, world.</fontsize>
3</body></html>
======================================================
我希望得到的 html 是:
1<html><body>
2<font size="7">hello, world.
3</font></body></html>
======================================================
命名空间必须是xmlns:xsl="http://www.w3.org/TR/WD-xsl",因为我怕好多机子不支持1999的那个。
---------------------------------------------------------------
1<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl">
2<xsl:template match="/">
3<html><body>
4<xsl:apply-templates select="article/Content"></xsl:apply-templates>
5</body></html>
6</xsl:template>
7<xsl:template match="article/Content">
8<xsl:eval no-entities="true">this.nodeTypedValue;</xsl:eval>
9</xsl:template>
10</xsl:stylesheet>
---------------------------------------------------------------
1<xsl:eval> 标记。 此标记用给定的脚本语言(JavaScript 或 Microsoft Visual Basic? Scripting Edition (VBScript))对表达式进行求值并返回一个结果。 通常,<xsl:eval> 节点允许您生成 XSL 本身通常不提供的数据。</xsl:eval></xsl:eval>