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

Subject: RE: [xsl] How to define a custom collation for Saxon8-8J
From: "Wolfgang Schindler" <w.schindler@xxxxxxx>
Date: Tue, 07 Nov 2006 16:02:15 +0100
Thanks a lot! The version with the "lang" parameter is working.

When I need specific rules that differ from the standard Java "de" locale, I
would have to set up my own RuleBasedCollator class. I found samples in the
Java tutorials how to write down the rules but I'm not well versed enough in
Java to wrap that properly up so that it works with Saxon. May I bother you
with asking for a working sample file with the right Java code in it if you
happen to have that readily available.

Thanks for taking your time to assist me!

Wolfgang


>>> "Michael Kay" <mike@xxxxxxxxxxxx> 07.11.2006 12:40:40 >>>
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 < C$ < A < C < 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