RE: [xsl] Re: $nodeset=true()

Subject: RE: [xsl] Re: $nodeset=true()
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Wed, 2 Jan 2002 18:07:31 -0000
> >The rules for comparing a node-set to a boolean have
> changed. ... In XPath 2.0, this expression is
> handled in
> >the same way as other comparisons between a sequence and a
> singleton: it is true if
> >$nodeset contains at least one node whose typed value is true.
> >----------------------------------------
> >
>
> This bothers me. What if the node set contains multiple nodes, some
> of which are true, some of which are false, and some of which are
> indeterminate?

As with $node-set='somestring" or $node-set=42 in XPath 1.0,
$node-set=true() will return true if there is at least one node $N in
$node-set such that $N=true().

In other words, the XPath 1.0 "existential" meaning of "=" (A=B is true if
some a in A is equal to some b in B) now covers all cases, removing this
awkward exception of comparison to a boolean. This change was necessary
because a singleton boolean is equivalent in the XPath 2.0 data model to a
sequence of length 1 whose only item is a boolean.

Those who are uncomfortable with the implicit existential semantics of "="
can now use "eq" instead, using "some" and "every" where necessary to make
the quantification explicit.

Mike Kay


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


Current Thread