I have an XSLT 1.0 stylesheet running using the XSL processor included with PHP (libxml). I want to get the same stylesheet to run on the Microsoft XSL processor MSXML 6.0 (msxml6.dll) ideally so the same stylesheet can run on either processor.
Unfortunately at the moment I would need to have two stylesheets - one for each processor.
This snippet invokes the node-set() function on the PHP processor;
<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>
This snippet invokes the node-set() function on the Microsoft processor;
<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>
If the input document was;
<root/>
The result of both stylesheets would be;
<b>world</b>
I want a single stylesheet that can run unchanged on the PHP processor and the Microsoft processor.
Although my real st开发者_开发问答ylesheet is about 400 lines long and the the node-set() function is used in four places, I hope the examples above demonstrates the problem.
Checked on libxml and msxsl, works in both cases.
Regards
Mike.
<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>
精彩评论