我有一个使用PHP附带的XSL处理器(libxml)运行的XSLT1.0样式表。理想情况下,我希望在Microsoft XSL处理器MSXML 6.0 (msxml6.dll)上运行相同的样式表,这样相同的样式表就可以在任何处理器上运行。
不幸的是,目前我需要两个样式表-每个处理器一个样式表。
这段代码调用PHP处理器上的node-set()函数;
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl">
<xsl:template match="root">
<xsl:variable name="rtf">
<a>hello</a><b>world</b>
</xsl:variable>
<xsl:variable name="ns" select="exsl:node-set($rtf)"/>
<xsl:copy-of select="$ns/b"/>
</xsl:template>
</xsl:transform>此代码段调用Microsoft处理器上的node-set()函数;
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
extension-element-prefixes="msxsl">
<xsl:template match="root">
<xsl:variable name="rtf">
<a>hello</a><b>world</b>
</xsl:variable>
<xsl:variable name="ns" select="msxsl:node-set($rtf)"/>
<xsl:copy-of select="$ns/b"/>
</xsl:template>
</xsl:transform>如果输入文档是;
<root/>两个样式表的结果都是;
<b>world</b>我想要一个单一的样式表,可以运行在PHP处理器和微软处理器不变。
虽然我的实际样式表大约有400行,并且在四个地方使用了node-set()函数,但我希望上面的示例说明了这个问题。
发布于 2011-12-11 04:09:31
在libxml和msxsl上检查,在这两种情况下都有效。
问候
麦克。
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:func="http://exslt.org/functions"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
extension-element-prefixes="exsl func msxsl"
>
<func:function name="msxsl:node-set">
<xsl:param name="node"/>
<func:result select="exsl:node-set($node)"/>
</func:function>
<xsl:template match="root">
<xsl:variable name="rtf">
<a>hello</a><b>world</b>
</xsl:variable>
<xsl:variable name="ns" select="msxsl:node-set($rtf)"/>
<xsl:copy-of select="$ns/b"/>
</xsl:template>
</xsl:transform>https://stackoverflow.com/questions/6252371
复制相似问题