Hi all,
I have a query that makes use of the UCA collation with the "numeric"
keyword [1] (e.g., for ensuring that "d2" sorts before "d12"), and I'm
seeking a way to confirm that the icu4j library is available on the BaseX
classpath before I run queries that depend on it. [2]
Even though I manually install the icu4j library into Basex's lib/custom
directory as specified in [3], I have sometimes forgotten to do so when,
for example, Homebrew upgraded BaseX, and as a result my query relying on
this collation began producing unexpected results. I've tried to make use
of the XQuery 4 fn:collation-available function [4], but so far I've been
unsuccessful.
Specifically, using BaseX 11.9 or 12 with icu4j-77.1.jar on macOS 15.5 (on
Apple Silicon), the following expression returns the expected result:
```
("d2", "d12") => sort("http://www.w3.org/2013/collation/UCA?numeric=yes")
```
The result, as expected, is ("d12", "d2"), when the library is present and
the opposite when it is absent.
But the following version, which introduces a conditional and the
fn:collation-available function, always takes the "else" path:
```
if (collation-available("http://www.w3.org/2013/collation/UCA?numeric=yes",
"compare")) then
("d2", "d12")
=> sort("http://www.w3.org/2013/collation/UCA?numeric=yes")
else
"UCA collation not present"
```
I expected this expression to return ("d12", "d2") but instead
received "UCA collation not present".
Am I misusing/misunderstanding how to use fn:collation-available?
Thanks!
Joe
[1] https://www.w3.org/TR/xpath-functions-31/#uca-collations
[2] https://docs.basex.org/main/Full-Text#collations
[3] https://docs.basex.org/main/Startup#full_distributions
[4] https://docs.basex.org/12/Standard_Functions#fn:collation-available