[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Boolean Short Curcuit
Well, this could happen because ancestor::page:error/@name exists, but doesn't match the name of any document($form-uri)/form/field... The XPath 2.0 spec says that with an expression (A and B), you've got no guarantee that B won't be called if A is false. That's different from 1.0, and it's designed to allow optimization of joins. In fact Saxon will generally evaluate A first, except in some join predicates: for example for $i in 1 to 10 for $j in 1 to 10 where ($j gt 5 and $i gt 3) return x might be rewritten as for $i in 1 to 10[. gt 3] for $j in 1 to 10[. gt 5] return x So the message is: you shouldn't be relying on order of evaluation; but in this case, I don't think that's likely to be the cause of the problem. The way to avoid reliance on order of evaluation is to rewrite (A and B) as (if (A) then B else false()). Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Alan [mailto:alan-xsl-list@xxxxxxxxx] > Sent: 23 September 2005 09:51 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Boolean Short Curcuit > > 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|