xsl-list
[Top] [All Lists]

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

2011-11-07 17:22:20
Hi again,

On 11/7/2011 6:14 PM, Andrew wrote:
On 7 November 2011 17:15, Wendell Piez<wapiez(_at_)mulberrytech(_dot_)com>  
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 'č' or
lower-case(substring(@word,1,1)) eq 'ř' or
lower-case(substring(@word,1,1)) eq 'š' or
lower-case(substring(@word,1,1)) eq 'ž') 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),'^([čřšž]|ch)')
   then replace(lower-case(@word),'^([čřšž]|ch).*$','$1')
   else lower-case(substring(cps:remove-diacritics(@word), 1, 1))

or at least:

if  (lower-case(substring(@word,1,1)) = ('č', 'ř','š','ž') ...

which could then be:

<xsl:variable name="seq" select="('č', 'ř','š','ž')" 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...

Quite true.

Then there's also

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

where $seq is 'čřšž'.

(I admit my brain has been permanently warped by XSLT 1.0.)

Cheers,
Wendell

--
======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

--~------------------------------------------------------------------
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>
--~--