Support #6039


Questions regarding QueryLibrary feature

Added by Jai Mashalkar 5 months ago. Updated 4 months ago.

Start date:
Due date:
% Done:


Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:


We have multiple xquery files used in our product, each of which have nested imports. We are trying to build a solution to optimize compilation of these xquery modules using the QueryLibrary feature provided in saxon ee . There are some errors we face, can you let us know your recommendation for solving the below issues:

Problem There are some xqueries XQ1, XQ2 which have a set of nested imports as shown below XQ1 /
A D /
B C / C / B

XQ2 - B - C - B

Preferable Solution: Separate QueryLibrary for each of A, B, C, D, XQ1 and XQ2. Steps to be followed:

  • Maintain a cache of QueryLibrary
  • When any import is encountered during compilation, check the cache - if present link it, if not compile into a QueryLibrary and then link, so that it can be used in subsequent imports.

Issues: - Repeated imports - C is imported from both A and D. When A and D are imported into XQ1, the functions of C get added twice and result in "Function already present" error. This happens as the functions from C don’t get recognized as duplicate in the QueryLibraryImpl - link function. - Question: Is it ok to override the link function to allow proper checking of this duplicate function, so that it works in our case? Would there be any risks to doing this? If so, any other workaround recommended?

- **Cyclic imports** - Trying to create QueryLibrary for modules that have cyclic dependencies leads to infinite import loop, or function not found error if empty modules are attached to get over the infinite loop. 

Question: Is this by design(the cyclic imports should be packaged together in a single QueryLIbrary), or is there a way to create separate QueryLibraries for each of the imports in this case?

Files (28.7 KB) Saxonica unit tests for XQueryCompiler Michael Kay, 2023-05-15 16:24

Please register to edit this issue

Also available in: Atom PDF