This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: xsl:fallback, nodesets, and different processors
- To: "Matthew Jaquish" <mjaquish at niku dot com>
- Subject: Re: [xsl] xsl:fallback, nodesets, and different processors
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Thu, 16 Aug 2001 09:39:05 +0100
- CC: XSL-List at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <00a301c125ee$83f8f660$ca2110ac@niku.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
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