Hi Christian,

Thank you very much! I had overlooked the information about the fallback
parameter. Using the latest snapshot, I can confirm that your suggested
code works.

Best,
Joe

p.s. Apologies for the errors in my note. In my rush to hit send I
incorrectly wrote in a couple of instances that the expected sort order
with "numeric=yes" and the library present is ("d12", "d2"), whereas the
correct sequence is actually ("d2", "d12").

p.p.s. I just noticed that the spec says to use a semicolon as the
delimiter between parameters in the UCA collation URI. [1] It seems BaseX
is forgiving and allows the use of ampersands.

[1]
https://qt4cg.org/specifications/xpath-functions-40/Overview.html#uca-collations
- unchanged in this respect from 3.1, I see.
https://www.w3.org/TR/xpath-functions-31/#uca-collations

On Mon, Jun 16, 2025 at 2:47 AM Christian Grün <[email protected]> wrote:

> Hi Joe,
>
> Choosing collation URIs can be confusing. The spec says [1]:
>
> “If the fallback parameter is omitted or takes the value yes [in the URI],
> and if the collation URI is well-formed according to the rules in this
> section, then the implementation must accept the collation URI, and should
> use the available collation that most closely reflects the user’s
> intentions.”
>
> This means that BaseX chooses a standard collation implementation if ICU
> is not present, and if the URI does not contain 'fallback=no'.
>
> However, this does not fully explain the surprising behavior that you
> observed. It was caused by a wrong interpretation of the 'compare'
> argument. I have improved this in the latest snapshot [2]. To be honest,
> this is still work in progress, as the spec offers few information on the
> details. The safest choice is to add the fallback behavior to the URI, and
> omit the second parameter:
>
> let $uri := `http://www.w3.org/2013/collation/UCA?numeric=yes&fallback=no`
> <http://www.w3.org/2013/collation/UCA?numeric=yes&fallback=no>
> return if (collation-available($uri)) then (
>   ("d2", "d12") => sort($uri)
> ) else (
>   "UCA collation not present"
> )
>
> Hope this helps,
> Christian
>
> [1]
> https://qt4cg.org/specifications/xpath-functions-40/Overview.html#uca-collations
> [2] https://files.basex.org/releases/latest/
>
>

Reply via email to