Re: [xsl] Can group-by treat its target it two ways?

Subject: Re: [xsl] Can group-by treat its target it two ways?
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Mon, 7 Nov 2011 23:14:53 +0000
On 7 November 2011 17:15, Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> wrote:
> Hi again,
>
> As long as we're tuning each other's code:
>
> On 11/5/2011 2:18 PM, Mark wrote:
>>
>> <xsl:for-each-group select="Word" group-by="if
>> (lower-case(substring(@word,1,1)) eq 'D
' or
>> lower-case(substring(@word,1,1)) eq 'E' or
>> lower-case(substring(@word,1,1)) eq 'E!' or
>> lower-case(substring(@word,1,1)) eq 'E>') then
>> lower-case(substring(@word,1,1)) else if
>> (lower-case(substring(@word,1,2)) eq 'ch') then 'ch' else
>> lower-case(substring(cps:remove-diacritics(@word), 1, 1))">
>
> Regular expressions?
>
> if matches(lower-case(@word),'^([D
EE!E>]|ch)')
> B  then replace(lower-case(@word),'^([D
EE!E>]|ch).*$','$1')
> B  else lower-case(substring(cps:remove-diacritics(@word), 1, 1))

or at least:

if  (lower-case(substring(@word,1,1)) = ('D
', 'E','E!','E>') ...

which could then be:

<xsl:variable name="seq" select="('D
', 'E','E!','E>')" as="xs:string+"/>

with:

if  (lower-case(substring(@word,1,1)) = $seq

It would be interesting to know how 'group by' gets evaluated, if its
once per item in the select this sort of tweak might make a
difference...


--
Andrew Welch
http://andrewjwelch.com

Current Thread