RE: [xsl] A smarter choose operation XSL 1.1

Subject: RE: [xsl] A smarter choose operation XSL 1.1
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 11 Jun 2009 09:26:31 +0100
> > select="(1.0, 1.7, 2.25, 3.0)[count(($opt.one, $opt.two, 
> $opt.three)[.])+1]"
> > 
> > The strange predicate [.] selects items in the sequence 
> that are true.
> 
> Would someone expand on this oddity please?
> I'm guessing 'true' in this case is the xslt version of 'true'...
> I.e. non-empty?

It will select all items in the sequence than have an effective boolean
value of true (other than numbers, because [] is overloaded for numbers). In
this case the items in the sequence are booleans, so it will select the
true() values and reject the false() ones.
> 
> How does that relate to
> ($opt.one, $opt.two, $opt.three)[.]  please?
> 
You can read it as

($opt.one, $opt.two, $opt.three)[. = true()]

if you prefer. But writing X=true() when X is a single boolean is always the
same as writing X.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay  

Current Thread