RE: [xsl] Re: XPath 2.0: Problems with the two boolean constants true and false

Subject: RE: [xsl] Re: XPath 2.0: Problems with the two boolean constants true and false
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 8 Oct 2003 21:40:39 +0100
> > Yes, this is a bug (or at any rate, it's a XSLT 2.0 feature that I 
> > haven't implemented yet but that isn't on my published list of 
> > features that I haven't implemented yet - there are 
> probably quite a 
> > few of these, and for the time being I am treating them as 
> bugs in the 
> > documentation rather than bugs in the code).
> >
> > What's actually happening is that no type checking or conversion of 
> > parameters is being done on the apply-templates call, but the code 
> > that references the parameters is assuming they are of the declared 
> > type. The net result is that the "A and B" is taking the effective 
> > boolean value of the value actually passed in the 
> parameters, and the 
> > effective boolean value of the string 'false' is true.
> 
> Actually, the parameters are converted to booleans but not 
> using the cast
>    xs:boolean($arg).
> 
> In reality the convertion is done using the EBV of the 
> supplied arguments.

The values aren't being converted at the point where the template is
called, they are being converted at the point where they are used as
operands to "and".
> 
> This makes 'false' into true

If she be false, O, then heaven mocks itself!
    Othello III 3

Yes. This is what the EBV rule does, and it is compatible with XPath
1.0. There are good reasons for retaining this rule. For example,
recursive templates that break text into words often test to see if the
supplied string is empty as their terminating condition, with a test
such as <xsl:if test="$param">. If "false" converted to false, then the
seven lines in Othello that end in the word "false" would be handled
incorrectly. 

> 
> So what is the benefit of typing? In this case it simply does 
> not work and I have to do it myself in code -- I am forced to 
> produce ugly code because the so advertised typing does not work.

There's a bug in the Saxon implementation, I don't see how that enables
you to draw conclusions about the usefulness of facilities in the
language?

Michael Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread