Subject: Re: [xsl] xsl:fallback, nodesets, and different processors From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Thu, 16 Aug 2001 09:39:05 +0100 |
Hi Matthew, > I am a bit confused by the <xsl:fallback> element. Perhaps someone > can help me out with a strategy for the following problem. To make > things easier, I have simplified my XSL below. > > I want to modify my template to use the built-in XSLT 1.0 nodeset > support but also still support the older xalan processor that uses > the xalan:nodeset extension for the same thing. (You mean the built-in XSLT 1.1 RTF-to-nodeset conversion, not XSLT 1.0.) The xsl:fallback element is for use with new or extension *elements*. If you nest xsl:fallback within a new or extension element, then a processor will use the content of the xsl:fallback if it doesn't recognise the element. For example, if you wanted to use the XSLT 1.1 xsl:document element, or fall back on the redirect:write element, then you could do: <xsl:document href="..."> ... <xsl:fallback> <redirect:write file="..."> ... </redirect:write> </xsl:fallback> </xsl:document> What you want to do, however, is test whether the processor supports XSLT 1.1. You can do that by testing the system property 'xsl:version', as follows: <xsl:template match="table"> <xsl:choose> <xsl:when test="system-property('xsl:version') >= 1.1"> <xsl:for-each select="$cellFilter/table/cell"> ... </xsl:for-each> </xsl:when> <xsl:otherwise> <xsl:for-each select="xalan:nodeset($cellFilter)/table/cell"> ... </xsl:for-each> </xsl:otherwise> </xsl:choose> </xsl:template> I would also recommend that you use the function-available() function to test whether xalan:nodeset() is available before you use it: <xsl:template match="table"> <xsl:choose> <xsl:when test="system-property('xsl:version') >= 1.1"> <xsl:for-each select="$cellFilter/table/cell"> ... </xsl:for-each> </xsl:when> <xsl:when test="function-available('xalan:nodeset')"> <xsl:for-each select="xalan:nodeset($cellFilter)/table/cell"> ... </xsl:for-each> </xsl:when> <xsl:otherwise> <xsl:message terminate="yes"> This stylesheet requires a processor that implements XSLT 1.1 or Xalan. </xsl:message> </xsl:otherwise> </xsl:choose> </xsl:template> I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xsl:fallback, nodesets, a, Aleksei Valikov | Thread | [xsl] Has this bug of MSXML3 fixed?, MURAKAMI Shinyu |
Re: [xsl] getting XSL to output XSL, Jeni Tennison | Date | RE: [xsl] XPath Query Builder, John Maughan |
Month |