[xsl] Boolean Short Curcuit

Subject: [xsl] Boolean Short Curcuit
From: Alan <alan-xsl-list@xxxxxxxxx>
Date: Fri, 23 Sep 2005 04:50:51 -0400
In Saxon 8.(4|5).

I'm calling this function.

<xsl:function name="page:field" as="element()">
  <xsl:param name="name" as="xs:string"/>
  <xsl:sequence select="document($form-uri)/form/field[name = $name][1]"/>
</xsl:function>

During this template match. Note that I'm performing a test to see
if the parameter exists. I expect that when it doesn't exist, the
function part of the test will not be called.

<xsl:template
    match="page:message[ancestor::page:error[@name]
        and page:field(ancestor::page:error/@name)/error]"
    mode="page:page">
<page:message><xsl:value-of
    select="page:field(ancestor::page:error/@name)/error"/></page:message>
</xsl:template>

But it appears to be getting called.

Recoverable error of :
  XPTY0004: An error occurred matching pattern
  {page:message[ancestor::page:error[@name] and
        page:field(ancestor::page:error/@name)/error]}
  : An empty sequence is not allowed as the result of function page:field()

I can provide more context if necessary. I tried if/else statements
in the call to page:field, but that still produced the error.

Thanks.

--
Alan Gutierrez - alan@xxxxxxxxx
    - http://engrm.com/blogometer/index.html
    - http://engrm.com/blogometer/rss.2.0.xml

Current Thread