RE: [xsl] Saxon bug in short-circuiting of expressions?

Subject: RE: [xsl] Saxon bug in short-circuiting of expressions?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 24 Jul 2006 13:57:21 +0100
> Applying the following stylesheet to itself or on any other 
> instance, I'd expect it would produce no errors and no output.
> 
>   <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>     <xsl:output method="text"/>
>     <xsl:template match="/">
>       <xsl:if test="function-available('hoge') and 
> hoge()">moge</xsl:if>
>     </xsl:template>
>   </xsl:stylesheet>
> 
> If I try it with xsltproc, that is exactly what I get (no 
> errors, no output). But trying it with Saxon, I get a fatal error:
> 
>   Error in expression function-available('hoge') and hoge(): 
> Unknown system function: hoge

The function hoge() is not in a namespace. Therefore it has to be a system
function, not an extension function. Referring to a system function that
doesn't exist is a static error, that is, it doesn't depend on whether the
function call is actually executed or not. The sentence I quoted from XSLT
1.0 section 14.2:

"An XSLT processor must not signal an error merely because an expression
contains an extension function for which no implementation is available."

refers explicitly to extension functions, defined by: "If a FunctionName in
a FunctionCall expression is not an NCName (i.e. if it contains a colon),
then it is treated as a call to an extension function."

For system functions the relevant statement is at the end of section 4:

"the function library consists of the core function library together with
the additional functions defined in [12 Additional Functions] and extension
functions as described in [14 Extensions]; it is an error for an expression
to include a call to any other function"

The 1.0 spec doesn't make a very clear distinction between static and
dynamic errors, but the text makes it fairly clear that it is describing a
static condition (an expression including a particular function call) rather
than a dynamic condition (the call being evaluated).

However, if you change the xsl:stylesheet element to say version="2.0", then
forwards compatibility comes into play, and no error is reported, because of
the rule that you originally quoted.

Michael Kay
http://www.saxonica.com/

Current Thread