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

Subject: [xsl] Saxon bug in short-circuiting of expressions?
From: "Michael(tm) Smith" <smith@xxxxxxxxxxxxxxxxxx>
Date: Mon, 24 Jul 2006 12:08:05 +0200
I have a question about a difference in the way that Saxon handles
evaluation of calls to unknown functions in boolean expressions.

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

I know that the "Forwards-Compatible Processing" section of the
XSLT 1.0 spec mentions that if an

  expression calls a function with an unprefixed name that is not
  part of the XSLT library, then an error must not be signaled
  unless the function is actually called.

But I'd think that Saxon would just short-circuit the expression,
never getting to actually evaluating the right operand -- the call
to the hoge() function -- since the XPath spec says:

  An and expression is evaluated by evaluating each operand and
  converting its value to a boolean as if by a call to the boolean
  function. The result is true if both values are true and false
  otherwise. The right operand is not evaluated if the left
  operand evaluates to false.

In this case, function-available('hoge') evaluates to false, so it
seems like the call to hoge() should not be getting evaluated.

Or am I misreading the spec?

  --Mike

Current Thread