xsl-list
[Top] [All Lists]

[xsl] A nice way to implement the ANDing of the comparison of pairs of items in a sequence?

2013-09-05 13:51:42
Hi Folks,

The value of this variable is a sequence of strings:

<xsl:variable name="checkPairs" 
     select="('Sally', 'Sally', 'Beth', 'Beth', 'Mary', 'Mary')" 
as="xs:string*"/>

I want to compare consecutive items and then AND the result of the comparisons. 

That is, compare the first string to the second string, the third string to the 
fourth string, the fifth string to the sixth string, and so on. Then AND the 
results together.

Thus,

    ('Sally' eq 'Sally') and ('Beth' eq 'Beth') and ('Mary' eq 'Mary')

returns true.

But if the variable is this:

<xsl:variable name="checkPairs" 
     select="('Sally', 'Beth', 'Beth', 'Beth', 'Mary', 'Mary')" 
as="xs:string*"/>

the result is false since 

    ('Sally' eq 'Beth') and ('Beth' eq 'Beth') and ('Mary' eq 'Mary')

is false.

Is there a nice way to implement this?

/Roger

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--