[Bug 3821] Enable element-available() to detect (extension) declarations

http://www.w3.org/Bugs/Public/show_bug.cgi?id=3821





------- Comment #1 from mike@saxonica.com  2006-10-13 12:52 -------
Thanks for the comment. We're well past the closing date for comments on the
Candidate Recommendation, I'm afraid. We're still interested in reports of
errors or inconsistencies, but not in suggestions for improvement.

>I don't see any reason why it shouldn't also return true() on supported XSLT declarations.

It was defined this way in XSLT 1.0, and is retained that way (a) for backwards
compatibility, and (b) because there is no overriding motivation to change it.
I've never been sure whether it was a deliberate decision to confine it to
instructions in 1.0 (if there was, one might have expected the function to be
named "instruction-available"), but certainly that's the way the spec was
written, and the use-case for which the construct was designed was entirely
concerned with conditional execution of instructions, in stylesheets designed
to run under more than one version of XSLT, or in stylesheets invoking vendor
extensions (which can only take the form of instructions). The point was to
allow a stylesheet to write:

<xsl:choose>
  <xsl:when test="element-available('xsl:sequence')">
    <xsl:sequence select="$x"/>
  </xsl:when>
  <xsl:otherwise>
    <xsl:copy-of select="$x"/>
  </xsl:otherwise>
</xsl:choose>

and thus to write stylesheets which will work on both XSLT 1.0 and 2.0
processors, while still taking advantage of 2.0 facilities when available.

You can't wrap a conditional around a declaration in this kind of way.

What you can do in 2.0 is to use xsl:use-when. For example if XSLT 3.0
introduced a new declaration xsl:input-format, you could write

<xsl:input-format use-when="system-property('xsl:version')='3.0')"/>

>By the way, aren't the following elements instuctions?
xsl:matching-substring
xsl:non-matching-substring
xsl:otherwise
xsl:output-character
xsl:sort
xsl:when
xsl:with-param

No, they aren't. There are four kinds of elements in the XSLT namespace: those
that are instructions, those that are declarations, those that are both (for
example xsl:variable) and those that are neither (like those you have listed
above).

Michael Kay
(personal response)

Received on Friday, 13 October 2006 12:52:25 UTC