saxon:import-query
The saxon:import-query
element is a top-level declaration that causes an
XQuery library module to be imported into the stylesheet.
Category: declaration
Content: none
Permitted parent elements:
xsl:stylesheet
; xsl:transform
Attributes
|
|
The (absolute or relative) URI of the XQuery module. |
|
|
Identifies the module namespace of the imported module. |
Details
The namespace
attribute is required, and identifies the module namespace of the XQuery library module
to be imported.
The location of the XQuery library module can be provided in one of two ways:
- In Saxon-EE, XQuery library modules can be compiled (from a Java application) using the
XQueryCompiler.compileLibrary()
method, and can then be made available to an XSLT compiler using theXsltCompiler.importXQueryEnvironment()
method. - Alternatively, the
href
attribute can be used to specify the location of the source code of the XQuery library module. (Thehref
attribute is ignored if a compiled version of the library is known to the compiler.)
The effect is that the public functions and variables declared in the library module become available for reference from any XPath expression in the stylesheet. They are available in all modules of the stylesheet.
Only the functions and variables actually defined in the given XQuery module become available for reference. Functions
and variables that the specified module imports from other XQuery modules are not imported (though they can be referenced indirectly). This follows
the semantics of XQuery's import module
declaration.
Functions and variable annotated as %private
are not imported.
The imported functions and variables do not have any specific import precedence. A static error occurs if the import leads to any duplicated function or variable names.
The saxon:import-xquery
declaration has two optional attributes. The
href
attribute is the (absolute or relative) URI of the XQuery module. The
namespace
attribute identifies the module namespace of the imported module.
If href
alone is specified, then the module is loaded from the given
location. If namespace
alone is specified, then the module must already be
present in Saxon's Configuration
object (you can share a Configuration
between multiple stylesheets, which
means that imported XQuery modules will not need to be recompiled for each one). If both
attributes are specified, then Saxon uses an already-loaded module for the namespace if it
can, otherwise it fetches it from the specified location, and checks that the namespace is
correct. It is recommended to specify both attributes.
Stylesheets using saxon:import-query
cannot be exported to SEF files.