Saxon and strange behaviour of xsl:sort with lang

Hi, I have hit strange behaviour when invoking Saxon from oXygen. It seems that lang attribute is not honoured when used on xsl:sort while collation works properly. Plese see following transformation: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0"> <xsl:variable name="data" select="('Zdena', 'Chvojí', 'Cimbál', 'Čočka')"/> <xsl:template name="main"> <xsl:for-each select="$data"> <xsl:sort select="." lang="cs"/> <xsl:value-of select="."/> <xsl:text>, </xsl:text> </xsl:for-each> <xsl:text> </xsl:text> <xsl:for-each select="$data"> <xsl:sort select="." collation="http://saxon.sf.net/collation?lang=cs"/> <xsl:value-of select="."/> <xsl:text>, </xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet> It should produce the following result (at it produces it when Saxon is invoked from command-line): Cimbál, Čočka, Chvojí, Zdena, Cimbál, Čočka, Chvojí, Zdena, But when run from oXygen output is wrong, lang="cs" is not honoured: Chvojí, Cimbál, Čočka, Zdena, Cimbál, Čočka, Chvojí, Zdena, Is there anything in Saxon integration which interferes with lang? Or perhaps JVM issue? Thanks for englightenment, Jirka -- ------------------------------------------------------------------ Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz ------------------------------------------------------------------ Professional XML consulting and training services DocBook customization, custom XSLT/XSL-FO document processing ------------------------------------------------------------------ OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 member ------------------------------------------------------------------

Hi Jirka, I get the same results both from command line and from oXygen. We tested this on Mac, Windows and Linux. Can you try without the lang attribute from the command line - I suspect you will get the same result as with lang="cs" on that machine. Anyway, we will investigate more on what is happening and come back with more details as soon as we have them. Best Regards, George -- George Cristian Bina <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com On 7/24/12 4:58 PM, Jirka Kosek wrote:
Hi,
I have hit strange behaviour when invoking Saxon from oXygen. It seems that lang attribute is not honoured when used on xsl:sort while collation works properly. Plese see following transformation:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
<xsl:variable name="data" select="('Zdena', 'Chvojí', 'Cimbál', 'Čočka')"/>
<xsl:template name="main"> <xsl:for-each select="$data"> <xsl:sort select="." lang="cs"/> <xsl:value-of select="."/> <xsl:text>, </xsl:text> </xsl:for-each> <xsl:text> </xsl:text> <xsl:for-each select="$data"> <xsl:sort select="." collation="http://saxon.sf.net/collation?lang=cs"/> <xsl:value-of select="."/> <xsl:text>, </xsl:text> </xsl:for-each> </xsl:template>
</xsl:stylesheet>
It should produce the following result (at it produces it when Saxon is invoked from command-line):
Cimbál, Čočka, Chvojí, Zdena, Cimbál, Čočka, Chvojí, Zdena,
But when run from oXygen output is wrong, lang="cs" is not honoured:
Chvojí, Cimbál, Čočka, Zdena, Cimbál, Čočka, Chvojí, Zdena,
Is there anything in Saxon integration which interferes with lang? Or perhaps JVM issue?
Thanks for englightenment,
Jirka
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user

On 24.7.2012 16:44, George Cristian Bina wrote:
I get the same results both from command line and from oXygen. We tested this on Mac, Windows and Linux. Can you try without the lang attribute from the command line - I suspect you will get the same result as with lang="cs" on that machine.
Hi George, output without lang="cs" is different on command-line and same in oXygen. I even used used oXygen local JRE and saxon9ee.jar bundled with oXygen to test it. And there is still difference.
Anyway, we will investigate more on what is happening and come back with more details as soon as we have them.
I don't know whether this could be related, but I recently installed 64-bit version of oXygen 14. Thanks for investigation, Jirka -- ------------------------------------------------------------------ Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz ------------------------------------------------------------------ Professional XML consulting and training services DocBook customization, custom XSLT/XSL-FO document processing ------------------------------------------------------------------ OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 member ------------------------------------------------------------------

Hi Jirka, I investigated the problem a little bit. When the Java VM is started it takes the default locale from the platform. In your case I suspect this is Czech. But when you use Oxygen, Oxygen does not have support in the GUI for Czech so you probably use it in English. Depending on the language the user has chosen, Oxygen will also set this language as the default locale. So when running from Oxygen with English-translated labels, the default locale for the Java VM is English. Now for the command line execution: From what I've tested, regardless of the value which you set in the @sort attribute, the behavior is the same. So if I have something like:
<xsl:sort select="." lang="en"/>
in the XSL the following command line will properly sort according to the Czech rules:
java -Duser.language=cs -Duser.country=CZ -jar lib/saxon9ee.jar -it:main -xsl:D:/projects/eXml/samples/test.xsl
and if I run:
java -Duser.language=en -Duser.country=EN -jar lib/saxon9ee.jar -it:main -xsl:D:/projects/eXml/samples/test.xsl
the nodes are sorted according to English rules. Do you obtain the same behavior on your side? I looked in the Saxon code and regardless of the @sort attribute value the method:
net.sf.saxon.java.JavaCollationFactory.makeCollation(Configuration, String, Properties)
does not receive any value for the "lang" key property and thus the code falls back to:
collator = Collator.getInstance(); // use default locale
which is "English" when running in Oxygen or Czech when running the command line. So I think this is a bug in Saxon because the code which deals with the language from "net.sf.saxon.expr.sort.SortKeyDefinition" avoids setting any property value if the language expression is a string literal (which it always is):
if(languageX.length() != 0 && !(language instanceof StringLiteral)) { net.sf.saxon.lib.ConversionRules rules = config.getConversionRules(); net.sf.saxon.type.ValidationFailure vf = StringConverter.STRING_TO_LANGUAGE.validate(languageX); if(vf != null) throw new XPathException("The lang attribute of xsl:sort must be a valid language code", "XTDE0030"); props.setProperty("lang", languageX); }
Regards, Radu Radu Coravu <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com On 7/24/2012 8:23 PM, Jirka Kosek wrote:
On 24.7.2012 16:44, George Cristian Bina wrote:
I get the same results both from command line and from oXygen. We tested this on Mac, Windows and Linux. Can you try without the lang attribute from the command line - I suspect you will get the same result as with lang="cs" on that machine.
Hi George, output without lang="cs" is different on command-line and same in oXygen. I even used used oXygen local JRE and saxon9ee.jar bundled with oXygen to test it. And there is still difference.
Anyway, we will investigate more on what is happening and come back with more details as soon as we have them.
I don't know whether this could be related, but I recently installed 64-bit version of oXygen 14.
Thanks for investigation,
Jirka
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user

On 25.7.2012 9:22, Oxygen XML Editor Support wrote:
Do you obtain the same behavior on your side?
I looked in the Saxon code and regardless of the @sort attribute value the method:
net.sf.saxon.java.JavaCollationFactory.makeCollation(Configuration, String, Properties)
does not receive any value for the "lang" key property and thus the code falls back to:
collator = Collator.getInstance(); // use default locale
which is "English" when running in Oxygen or Czech when running the command line.
So I think this is a bug in Saxon because the code which deals with the language from "net.sf.saxon.expr.sort.SortKeyDefinition" avoids setting any property value if the language expression is a string literal (which it always is):
Radu, many thanks for deep investigation. It seems that you are right. Sorry for making noise, I know this was working in past, so probably some regression was introduced in Saxon not Oxygen. I will follow up on saxon mailing list. Jirka -- ------------------------------------------------------------------ Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz ------------------------------------------------------------------ Professional XML consulting and training services DocBook customization, custom XSLT/XSL-FO document processing ------------------------------------------------------------------ OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 member ------------------------------------------------------------------

On 25.7.2012 12:50, Jirka Kosek wrote:
Radu, many thanks for deep investigation. It seems that you are right. Sorry for making noise, I know this was working in past, so probably some regression was introduced in Saxon not Oxygen. I will follow up on saxon mailing list.
Hi Radu, indeed it was bug in Saxon, it is fixed now: https://dev.saxonica.com/community/issues/1596#change-1796 Thanks for help, Jirka -- ------------------------------------------------------------------ Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz ------------------------------------------------------------------ Professional XML consulting and training services DocBook customization, custom XSLT/XSL-FO document processing ------------------------------------------------------------------ OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 member ------------------------------------------------------------------
participants (3)
-
George Cristian Bina
-
Jirka Kosek
-
Oxygen XML Editor Support