Subject: Re: [xsl] Boolean Value of a Sequence of Booleans From: "Dimitre Novatchev dnovatchev@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 5 Dec 2014 21:11:17 -0000 |
I think you could just use: boolean($vSeq[.][1]) In XPath 3.0 one could use: fold-right($seq, true(), function(x as xs:boolean, y as xs:boolean) as xs:boolean {x and y}) and in XSLT 2.0 one could use the FXSL function f:foldr() and f:and() in a similar way: http://fxsl.cvs.sourceforge.net/viewvc/fxsl/fxsl-xslt2/f/func-foldr.xsl? view=markup And even in XSLT 1.0 one can use the FXSL function f:some-true() : http://fxsl.cvs.sourceforge.net/viewvc/fxsl/fxsl-xslt2/f/someTrue.xsl?rev ision=1.1&view=markup I believe that (at least in Haskell) foldr() is defined in such a way that it will short-circuit. Cheers, Dimitre On Fri, Dec 5, 2014 at 12:39 PM, Eliot Kimber ekimber@xxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > I think I must be forgetting something fundamental, but I'm not figuring > out how to do something that should be fundamental, I think. > > Using XSLT2, I'm examining all the items in a key() map to see if any > entries in the map have more than 1 item. I'm doing this by iterating over > the keys. I'm then producing a boolean for each iteration and capturing > the sequence of booleans in a variable. > > My thinking was that I could then just AND the sequence to determine if > any of the items had more than 1 item. But I see that boolean() and not() > don't operate on sequences of booleans. Hmph. > > I realize thinking about it now that I can only put true() items in my > sequence and then just check the first one. > > But my question still remains: is there a built-in way to apply boolean > operators to a sequence of booleans or would I need to write my own > function? Obviously, if I was writing my own function I'd just use > recursion to walk the sequence, which would allow early termination for > and() and or(). > > Have I missed something obvious or not so obvious? I am I just thinking > about this particular problem the wrong way? > > Thanks, > > Eliot > > bbbbb > Eliot Kimber, Owner > Contrext, LLC > http://contrext.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Boolean Value of a Sequence o, Eliot Kimber ekimber | Thread | Re: [xsl] Boolean Value of a Sequen, G. Ken Holman g.ken. |
[xsl] Boolean Value of a Sequence o, Eliot Kimber ekimber | Date | Re: [xsl] unparsed-text and normali, G. Ken Holman g.ken. |
Month |