Collation in BaseX and Java

Tuesday, 5 July 2016 · 5 messages · last reply 6 Jul 2016
KK
Kristian Kankainen5 Jul 2016 12:58 #
Hello! In a lexicographic application I need a custom collation for ordering. The documentation for XML, Xquery and XSLT all somehow state that system available collations are to be used and all seem to support custom collations by specifying the URI. Is this possible also for custom created Java collators? I have been looking at the Java docs [1] and it looks easy enough for me, but I would like to get an affirmative from this list that it does work with BaseX. My initial guesses is that I'd need to package my collator class as a jar and install it in the Xquery module repository [2]. But how to use it from there I'm not sure. Is BaseX able to automatically use it correctly if I specify the correct URI as collation in the prolog "|declare| |default| |collation 'URI';|"? I'd me more than glad to write about it in the documentation/wiki if I get it working. Cheers! Kristian [1] http://docs.oracle.com/javase/7/docs/api/java/text/RuleBasedCollator.html [2] http://docs.basex.org/wiki/Repository
KK
Kristian Kankainen5 Jul 2016 14:35 #
Hello again! I found a good amount of information [1] on how to do a custom Java collation for Apache Derby, including all the packaging and metainformation. Now the only uncertain point for me is: * where should I put the collation packaged as jar file * how to make BaseX aware of the new collation Best regards Kristian K [1] https://blogs.oracle.com/kah/entry/user_defined_collation_in_apache 05.07.2016 13:58 Kristian Kankainen kirjutas:
Quoted text · Kristian Kankainen · 29 lines
> > Hello! > > In a lexicographic application I need a custom collation for ordering. > The documentation for XML, Xquery and XSLT all somehow state that > system available collations are to be used and all seem to support > custom collations by specifying the URI. Is this possible also for > custom created Java collators? > > I have been looking at the Java docs [1] and it looks easy enough for > me, but I would like to get an affirmative from this list that it does > work with BaseX. > > My initial guesses is that I'd need to package my collator class as a > jar and install it in the Xquery module repository [2]. But how to use > it from there I'm not sure. Is BaseX able to automatically use it > correctly if I specify the correct URI as collation in the prolog > "|declare| |default| |collation 'URI';|"? > > I'd me more than glad to write about it in the documentation/wiki if I > get it working. > > Cheers! > Kristian > > [1] > http://docs.oracle.com/javase/7/docs/api/java/text/RuleBasedCollator.html > [2] http://docs.basex.org/wiki/Repository >
CG
Christian Grün5 Jul 2016 17:55 #
Hi Kristian, I would guess that custom Java collations won’t be detected automatically, but I might be wrong ;) Did you try something similar with other query processors (most notably, Saxon)? If it’s possible for you to provide me with a little self-contained example, I could have a second look. Cheers Christian
Quoted text · Kristian Kankainen · 48 lines
On Tue, Jul 5, 2016 at 2:35 PM, Kristian Kankainen <kristian at keeleleek.ee> wrote: > Hello again! > > I found a good amount of information [1] on how to do a custom Java > collation for Apache Derby, including all the packaging and metainformation. > > Now the only uncertain point for me is: > * where should I put the collation packaged as jar file > * how to make BaseX aware of the new collation > > Best regards > Kristian K > > [1] https://blogs.oracle.com/kah/entry/user_defined_collation_in_apache > > > 05.07.2016 13:58 Kristian Kankainen kirjutas: > > Hello! > > In a lexicographic application I need a custom collation for ordering. The > documentation for XML, Xquery and XSLT all somehow state that system > available collations are to be used and all seem to support custom > collations by specifying the URI. Is this possible also for custom created > Java collators? > > I have been looking at the Java docs [1] and it looks easy enough for me, > but I would like to get an affirmative from this list that it does work with > BaseX. > > My initial guesses is that I'd need to package my collator class as a jar > and install it in the Xquery module repository [2]. But how to use it from > there I'm not sure. Is BaseX able to automatically use it correctly if I > specify the correct URI as collation in the prolog "declare default > collation 'URI';"? > > I'd me more than glad to write about it in the documentation/wiki if I get > it working. > > Cheers! > Kristian > > [1] > http://docs.oracle.com/javase/7/docs/api/java/text/RuleBasedCollator.html > [2] http://docs.basex.org/wiki/Repository > >
KK
Kristian Kankainen5 Jul 2016 21:43 #
Hi Christian, I got the Locale working in Java now, and since it is a full Java Locale, I started hoping it might even work automatically (e.g show up in the list generated by [2]). I will send a full little self-contained example, but first, could you tell me or add it to the docs, what it means to "If the ICU Library is downloaded and added to the classpath ..." [1]. I think I should act the same with my locale jar file. Does "added to the classpath" mean simply the same as installing to the Xquery module repositorium? Best Kristian [1] http://docs.basex.org/wiki/XQuery_3.1#Collations [2] Xquery code: declare namespace locale = "java:java.util.Locale"; (locale:getAvailableLocales() ! locale:getLanguage(.)) => distinct-values() => sort() 05.07.2016 18:55 Christian Grün kirjutas:
Quoted text · Christian Grün · 61 lines
> Hi Kristian, > > I would guess that custom Java collations won’t be detected > automatically, but I might be wrong ;) Did you try something similar > with other query processors (most notably, Saxon)? > > If it’s possible for you to provide me with a little self-contained > example, I could have a second look. > > Cheers > Christian > > > On Tue, Jul 5, 2016 at 2:35 PM, Kristian Kankainen > <kristian at keeleleek.ee> wrote: >> Hello again! >> >> I found a good amount of information [1] on how to do a custom Java >> collation for Apache Derby, including all the packaging and metainformation. >> >> Now the only uncertain point for me is: >> * where should I put the collation packaged as jar file >> * how to make BaseX aware of the new collation >> >> Best regards >> Kristian K >> >> [1] https://blogs.oracle.com/kah/entry/user_defined_collation_in_apache >> >> >> 05.07.2016 13:58 Kristian Kankainen kirjutas: >> >> Hello! >> >> In a lexicographic application I need a custom collation for ordering. The >> documentation for XML, Xquery and XSLT all somehow state that system >> available collations are to be used and all seem to support custom >> collations by specifying the URI. Is this possible also for custom created >> Java collators? >> >> I have been looking at the Java docs [1] and it looks easy enough for me, >> but I would like to get an affirmative from this list that it does work with >> BaseX. >> >> My initial guesses is that I'd need to package my collator class as a jar >> and install it in the Xquery module repository [2]. But how to use it from >> there I'm not sure. Is BaseX able to automatically use it correctly if I >> specify the correct URI as collation in the prolog "declare default >> collation 'URI';"? >> >> I'd me more than glad to write about it in the documentation/wiki if I get >> it working. >> >> Cheers! >> Kristian >> >> [1] >> http://docs.oracle.com/javase/7/docs/api/java/text/RuleBasedCollator.html >> [2] http://docs.basex.org/wiki/Repository >> >>
CG
Christian Grün6 Jul 2016 19:50 #
Quoted text · Kristian Kankainen · 4 lines
> first, could you tell me or add it to the docs, what it means to "If the ICU > Library is downloaded and added to the classpath ..." [1]. I think I should > act the same with my locale jar file. Does "added to the classpath" mean > simply the same as installing to the Xquery module repositorium?
Installed module will be added on the fly (which each call of an XQuery expression). If you are working with the zip/exe distributions, you can copy the ICU library into the project’s lib directory. Otherwise, you’ll have to manually add it to your java call, e.g. as follows:
  java -cp BaseX.jar;icu.jar org.base.BaseXGUI
Hope this helps Christian
Quoted text · Kristian Kankainen · 85 lines
> > Best > Kristian > > [1] http://docs.basex.org/wiki/XQuery_3.1#Collations > > [2] Xquery code: > declare namespace locale = "java:java.util.Locale"; > (locale:getAvailableLocales() ! locale:getLanguage(.)) > => distinct-values() > => sort() > > > > 05.07.2016 18:55 Christian Grün kirjutas: >> >> Hi Kristian, >> >> I would guess that custom Java collations won’t be detected >> automatically, but I might be wrong ;) Did you try something similar >> with other query processors (most notably, Saxon)? >> >> If it’s possible for you to provide me with a little self-contained >> example, I could have a second look. >> >> Cheers >> Christian >> >> >> On Tue, Jul 5, 2016 at 2:35 PM, Kristian Kankainen >> <kristian at keeleleek.ee> wrote: >>> >>> Hello again! >>> >>> I found a good amount of information [1] on how to do a custom Java >>> collation for Apache Derby, including all the packaging and >>> metainformation. >>> >>> Now the only uncertain point for me is: >>> * where should I put the collation packaged as jar file >>> * how to make BaseX aware of the new collation >>> >>> Best regards >>> Kristian K >>> >>> [1] https://blogs.oracle.com/kah/entry/user_defined_collation_in_apache >>> >>> >>> 05.07.2016 13:58 Kristian Kankainen kirjutas: >>> >>> Hello! >>> >>> In a lexicographic application I need a custom collation for ordering. >>> The >>> documentation for XML, Xquery and XSLT all somehow state that system >>> available collations are to be used and all seem to support custom >>> collations by specifying the URI. Is this possible also for custom >>> created >>> Java collators? >>> >>> I have been looking at the Java docs [1] and it looks easy enough for me, >>> but I would like to get an affirmative from this list that it does work >>> with >>> BaseX. >>> >>> My initial guesses is that I'd need to package my collator class as a jar >>> and install it in the Xquery module repository [2]. But how to use it >>> from >>> there I'm not sure. Is BaseX able to automatically use it correctly if I >>> specify the correct URI as collation in the prolog "declare default >>> collation 'URI';"? >>> >>> I'd me more than glad to write about it in the documentation/wiki if I >>> get >>> it working. >>> >>> Cheers! >>> Kristian >>> >>> [1] >>> http://docs.oracle.com/javase/7/docs/api/java/text/RuleBasedCollator.html >>> [2] http://docs.basex.org/wiki/Repository >>> >>> >

⚡Generated with XQuery