[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xsl:fallback, nodesets, and different processors
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|