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

Subject: Re: [xsl] Can group-by treat its target it two ways?
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Sat, 05 Nov 2011 18:10:03 +0000
>How can I make <xsl:for-each-group select="Word" group-by="lower-case(substring(@word,1,1))"> consider 'ch' as a single letter?

You can of course handle the special case as you do in your follow-up post, but I don't think there's a general solution in XSLT.

At the Java level, you can get a RuleBasedCollator for a given language, and you can create a CollationElementIterator that iterates over the collation units of a string given this collator; in your example the first collation unit will be 'ch'. I think there's enough information in the CollationElementIterator to support an extension function

collation-units(string, collation) -> string*

that splits any string into its collation units; and then you could of course do group-by="collation-units(., $czech-collation)[1]".

So I think it's possible in theory!

Michael Kay

Current Thread