Specifying Collations


DataDirect XQuery allows collations to be specified in the query, for example, in the query prolog or for a specific order by clause. The specified collation, however, is only used for expressions evaluated by the XQuery engine (see DataDirect XQuery® Architecture).

When DataDirect XQuery accesses a relational database, it uses the collation used by the database. For consistency, ensure that the collation used by DataDirect XQuery (which can be modified as explained below) is compatible with the collation used by the database. If multiple databases are accessed, ensure that their collations are compatible. For relational sources, the collation used by the database overrides any collation specified in the query.

DataDirect XQuery allows you to specify any of the following collations:

http://www.w3.org/2005/04/xpath-functions/collation/codepoint 
http://www.datadirect.com/xquery/collation?class=class_name 
 

where class_name is a fully-qualified name of a Java class that implements java.util.Comparator. If the collation will be used in functions such as contains() and starts-with(), this class must also implement java.text.RuleBaseCollator.

http://www.datadirect.com/xquery/collation?keyword=value[;keyword=value]... 
 

where the following keywords and values are valid:

lang
Specifies a value that is used to find the collation appropriate to a Java locale. A valid value is any value allowed for the langName or langDef parameters of java.lang.Locale. For example, for US English:
en-us
strength
{primary | secondary | tertiary | identical}. Specifies a level of comparison that DataDirect XQuery enforces when comparing strings. For example, A/B is a primary difference; a/á is a secondary difference; A/a is a tertiary difference; and a/a is identical. Therefore, if
strength=primary, A=a is true;
if strength=secondary, A=a is true, but a=á is false; and, if strength=tertiary, A=a is false.
decomposition
{none | standard | full}. Determines how the collator handles Unicode characters. Refer to your J2SE documentation for details about how these values affect comparisons of strings.

DataDirect XQuery uses the collation URI used by the Java Virtual Machine as the default collation. You can change this value using any of the following methods: