OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]

Subject: Re: DOCBOOK-APPS: Sorting and non-en_US indexes

* Jirka Kosek; <jirka@kosek.cz> on 24 Sep, 2002 wrote:
>default (usually English) I must specify language. E.g. if I want to
>sort something using Czech collating, I must specify it:
><xsl:sort select="..." lang="cs"/>

Ok so far means I got it correct, however the output is not sorted
according to the Language attribute. I must be doing something wrong ?

Here are the things I have done :

1) Create Compare_tr class  

package com.icl.saxon.sort;

import java.text.Collator;
import java.util.Locale;

// Copyright © International Computers Limited 1998
// See conditions of use

 * A Comparer used with lang="tr".
 * author Jirka Kosek (jirka@kosek.cz)
 * <p>
 * First seen in docbook-apps mailinglist
 * Modified for use with Turkish used with lang="tr"
 * @author Togan Muftuoglu (toganm@users.sourceforge.net>
public class Compare_tr extends TextComparer {

    int caseOrder = UPPERCASE_FIRST;

    * Compare two string objects, in three phases:
    * (a) ignoring accents and case
    * (b) if still equal, ignoring case
    * (c) if still equal, taking case into account
    * @return <0 if a<b, 0 if a=b, >0 if a>b

    public int compare(Object a, Object b) {

        Collator trCollator = Collator.getInstance(new Locale("tr",

        return trCollator.compare(a, b);


    public Comparer setCaseOrder(int caseOrder) {
        this.caseOrder = caseOrder;
        return this;


2) Modified autoidx.xsl as follows when there was <xsl:sort.. > I added
the lang="tr" 

<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [

<!ENTITY lowercase "'abc&#231;defg&#287;h&#305;ijklmno&#246;prs&#351;tu&#252;vyz'">
<!ENTITY uppercase "'ABC&#199;DEFG&#286;HI&#304;JKLMNO&#214;PRS&#350;TU&#220;VYZ'">

<!ENTITY primary   'normalize-space(concat(primary/@sortas, primary[not(@sortas)]))'>
<!ENTITY secondary 'normalize-space(concat(secondary/@sortas, secondary[not(@sortas)]))'>
<!ENTITY tertiary  'normalize-space(concat(tertiary/@sortas, tertiary[not(@sortas)]))'>

<!ENTITY sep '" "'>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

<!-- ==================================================================== -->
<!-- Derived from Jeni Tennison's work in the HTML case -->
<xsl:key name="letter"
         use="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>

<xsl:key name="primary"

<xsl:key name="secondary"
         use="concat(&primary;, &sep;, &secondary;)"/>

<xsl:key name="tertiary"
         use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/>

<xsl:key name="see-also"
         use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, seealso)"/>

<xsl:key name="see"
         use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see)"/>

<xsl:template name="generate-index">
  <xsl:variable name="terms" select="//indexterm[count(.|key('letter',
                                     translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;))[1]) = 1]"/>
  <xsl:variable name="alphabetical"
                select="$terms[contains(concat(&lowercase;, &uppercase;),
                                        substring(&primary;, 1, 1))]"/>
  <xsl:variable name="others" select="$terms[not(contains(concat(&lowercase;,
                                             substring(&primary;, 1, 1)))]"/>
    <xsl:if test="$others">
      <fo:block font-size="16pt"
        <xsl:call-template name="gentext">
          <xsl:with-param name="key" select="'index symbols'"/>
        <xsl:apply-templates select="$others[count(.|key('primary',
                                     &primary;)[1]) = 1]"
          <xsl:sort select="&primary;" lang="tr" />

3) I have imported the autoidx_tr.xsl into my customization

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

<xsl:import href="http://docbook.sourceforge.net/release/xsl/snapshot/fo/docbook.xsl"/>
<xsl:import href="/home/toganm/sgml/xsl/autoidx_tr.xsl"/>

4) LANG=tr ~/sbin/parser.sh indexturkce3.fo indexterm.002.xml \
~/sgml/xsl/fop-common.xsl >error.txt 2>&1

where parser.sh includes all the JAR paths including Compare_tr location
along with Catalog reseolvers  ( I use Saxon 6.5.2 with SunJava version "1.3.1_02"
Under Linux I normally have tr_TR-UTF-8 locale I have tried width the
LANG=tr and LANG=tr_TR-UTF-8 

5) When I do grep Compare error.txt tehreis no sign of Compare_tr being

[Loaded java.io.ObjectStreamClass$CompareClassByName from
[Loaded java.io.ObjectStreamClass$CompareMemberByName from
[Loaded com.icl.saxon.sort.NodeOrderComparer]
[Loaded com.icl.saxon.sort.LocalOrderComparer]
[Loaded com.icl.saxon.sort.Comparer]
[Loaded com.icl.saxon.sort.TextComparer]
[Loaded com.icl.saxon.sort.StringComparer]
[Loaded com.icl.saxon.sort.Compare_en]
[Loaded com.icl.saxon.sort.DoubleComparer]
[Loaded com.icl.saxon.sort.DescendingComparer] 

6) Result is wrong order of the alphabet ? So what is that I am missing  


Togan Muftuoglu

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]

Powered by eList eXpress LLC