Hi Rob, The default collation can come from a few different places. Each App Server has a default collation specified in the configuration, you can specify a default collation in the prolog of a main module, and maybe one or two other ways I can't think of off the top of my head. When no default collation is available (for example, if something is run on the task server), then the default default applies, which I think is http://marklogic.com/collation/.
Each function that uses a collation allows you to specify a collation, and if not specified, it will use the default collation. It is best practice to *always* specify your collation in your range query and lexicon built-in calls. This will ensure that your code will work in other contexts. Now as to why this code behaves this way (I am assuming that the function declared in options.xqy is supposed to be test:get-options, not local:get-options), I am not positive, but I think it is because xdmp:function calls appear to default to the codepoint collation. If you stick the following prolog in options.xqy, then both will return the root collation: declare default collation "http://marklogic.com/collation/"; So the moral of the story is: always explicitly specify your collation to avoid surprises. Collations are your friends. -Danny From: [email protected] [mailto:[email protected]] On Behalf Of Whitby, Rob, Springer Healthcare UK Sent: Monday, April 23, 2012 4:38 PM To: [email protected] Subject: [MarkLogic Dev General] error using xdmp:function() with function from another module Hi, This is weird, but the query below gives different results depending on if the function being applied is local or from another module. The default collation is "http://marklogic.com/collation/". xquery version "1.0-ml"; declare namespace test="test"; declare function local:get-options() { let $query := cts:element-range-query(xs:QName("foo"), "=", "bar") return cts:element-range-query-options($query) }; xdmp:apply(xdmp:function(xs:QName("local:get-options"))), xdmp:apply(xdmp:function(xs:QName("test:get-options"), "options.xqy")) => collation=http://marklogic.com/collation/ => collation=http://marklogic.com/collation/codepoint (: options.xqy :) xquery version "1.0-ml"; module namespace test="test"; declare function local:get-options() { let $query := cts:element-range-query(xs:QName("foo"), "=", "bar") return cts:element-range-query-options($query) }; Why does calling the function from another module set the wrong collation? (should add I'm using 5.01) Thanks Rob
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
