RE: [xsl] How to define a custom collation for Saxon8-8J

Subject: RE: [xsl] How to define a custom collation for Saxon8-8J
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 7 Nov 2006 11:40:40 -0000
This will vary from one product to another, but the facilities in Saxon are
defined at

http://www.saxonica.com/documentation/extensibility/collation.html

You should be able to get a collation suitable for German simply by using
lang="de" on xsl:sort, though it you need to use it for other operations
such as < and > then you will need to use a collation URI, which in Saxon is

http://saxon.sf.net/collation?lang=de

If you want to set up your own Java RuleBasedCollator you can; if the
relevant class is BasicGerman and it's on the classpath then you can use

http://saxon.sf.net/collation?class=BasicGerman

If you don't want to use Saxon-specific URIs, then you can implement your
own CollationURIResolver.

Saxon-specific questions are best asked on the saxon-help list or forum at
SourceForge.net

Michael Kay
http://www.saxonica.com/



> -----Original Message-----
> From: Wolfgang Schindler [mailto:w.schindler@xxxxxxx]
> Sent: 07 November 2006 11:22
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] How to define a custom collation for Saxon8-8J
>
> Hi,
>
> I defined a rudimentary German collation in a basicGerman.java file:
>
> String simpleRule ="a < d < A < D < b < c < d < e < f < g < h
> < i < j < k < l < m < n < o < p < q < r < s < t < u < v < w <
> x < y < z"; RuleBasedCollator basicGerman = new
> RuleBasedCollator (simpleRule);
>
> (Please note: It's far from perfect and doesn't cover
> everything needed for German)
>
> Then I wanted to use that collation for sorting in XSLT:
>
> <xsl:template match="myroot">
>   <myroot>
> 	<xsl:apply-templates>
> 		<xsl:sort select="stich"
> collation="file://D:/saxonsa8-8j/basicGerman"/>
>                 </xsl:apply-templates>
>   </myroot>
> </xsl:template>
>
> When I execute that XSLT I get the following error:
>
> Error at xsl:sort on line 10 of file:/D:/saxonsa8-8j/sort.xsl:
>   XTDE1035: Collation file://D:/saxonsa8-8j/basicGerman has
> not been defined Failed to compile stylesheet. 1 error detected.
>
> How is a collation "defined" for XSLT sorting?
>
> Many thanks in advance!
>
> Wolfgang

Current Thread