How to import common module namespaces in xquery

I have several xquery namespace files that were used in multiple files. I want to have namespaces in one common xquery file and import this file that I want to use.

Say for example

I have process-lib.xqy, util-lib.xqyand query-lib.xqy. I used them to import in multiple files, for example,

import module namespace util = "util" at "util-lib.xqy";
import module namespace process = "process" at "process-lib.xqy";
import module namespace query = "query" at "query-lib.xqy";

Now I tried to use them in one common file with the name common-import.xqyand import this file into several files.

when i tried this approach

import module namespace common-import= "common-import" at "common-import.xqy";

It throws an exception like prefix util has no namespace binding.

How to do it?

+4
source share
1 answer

, , , . XQuery :

Module imports are not transitive—that is, importing a module provides access only to function and variable declarations contained directly in the imported module. For example, if module A imports module B, and module B imports module C, module A does not have access to the functions and variables declared in module C.

. , - , , . common-import.xqy :

declare function common-import:test() { 
  util:test() 
};

, , . . .

+2

Source: https://habr.com/ru/post/1613630/


All Articles