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

Subject: Re: [xsl] A nice way to implement the ANDing of the comparison of pairs of items in a sequence?
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Fri, 6 Sep 2013 08:47:17 +0100
Yes, a filter expression is guaranteed to preserve the order of items in the
input sequence.

Michael Kay
Saxonica

On 6 Sep 2013, at 08:41, Wolfgang Laun wrote:

> I guess any implementation would use incrementing position values
> anyway, but is this kind of filtering *defined* to be stable, i.e.,
> preserving the relative order of items?
>
> -W
>
> On 05/09/2013, Michael Kay <mike@xxxxxxxxxxxx> wrote:
>>
>> How about
>>
>> deep-equal($v[position() mod 2 = 0], $v[position() mod 2 = 1])
>>
>> Michael Kay
>> Saxonica
>>
>> On 5 Sep 2013, at 19:51, Costello, Roger L. wrote:
>>
>>> 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

Current Thread