net.sf.saxon.query

Class QueryModule

public class QueryModule extends Object implements StaticContext

This class represents a query module, and includes information about the static context of the query module. The class is intended for internal Saxon use. User settings that affect the static context are made in the StaticQueryContext object, and those settings are copied to each QueryModule when the query module is compiled.
Constructor Summary
QueryModule(StaticQueryContext sqc)
Create a QueryModule for a main module, copying the data that has been set up in a StaticQueryContext object
QueryModule(Configuration config, QueryModule importer)
Create a QueryModule for a library module.
Method Summary
voidaddImportedNamespace(String uri)
Register that this module imports a particular module namespace

This method is intended for internal use.

voidaddImportedSchema(String targetNamespace, String baseURI, List locationURIs)
Add an imported schema to this static context.
voidbindUnboundFunctionCalls()
Bind function calls that could not be bound when first encountered.
voidbindUnboundVariables()
Bind unbound variables (these are typically variables that reference another module participating in a same-namespace cycle, since local forwards references are not allowed)
ExpressionbindVariable(StructuredQName qName)
Bind a variable used in a query to the expression in which it is declared.
voidcheckForCircularities(List compiledVars, XQueryFunctionLibrary globalFunctionLibrary)
Check for circular definitions of global variables.
voidcheckImportedFunctionSignature(XQueryFunction fd)
Check that all the types used in the signature of an imported function are available in the module of the caller of the function
voidcheckImportedType(SequenceType importedType, Declaration declaration)
Check that a SequenceType used in the definition of an imported variable or function is available in the importing module
StringcheckURIForPrefix(String prefix)
Get the URI for a prefix if there is one, return null if not.
voiddeclareActiveNamespace(String prefix, String uri)
Declare an active namespace, that is, a namespace which as well as affecting the static context of the query, will also be copied to the result tree when element constructors are evaluated.
voiddeclareFunction(XQueryFunction function)
Register a user-defined XQuery function.
voiddeclarePrologNamespace(String prefix, String uri)
Register a namespace that is explicitly declared in the prolog of the query module.
voiddeclareVariable(VariableDeclaration var)
Declare a global variable.
voidexplainGlobalFunctions(ExpressionPresenter out)
Output "explain" information about each declared function.
voidfixupGlobalFunctions()
Fixup all references to global functions.
List<GlobalVariableDefinition>fixupGlobalVariables(SlotManager globalVariableMap)
Fixup all references to global variables.
int[]getActiveNamespaceCodes()
Get an array containing the namespace codes of all active namespaces.
Map<String,HashSet<String>>getAllImportedSchemata()
For the top-level module only, get all the schema modules imported anywhere in the query.
StringgetBaseURI()
Get the base URI for a module
StringCollatorgetCollation(String name)
Get a named collation.
ConfigurationgetConfiguration()
Get the Saxon Configuration
intgetConstructionMode()
Get the current construction mode
DecimalFormatManagergetDecimalFormatManager()
Get a DecimalFormatManager to resolve the names of decimal formats used in calls to the format-number() function.
StringgetDefaultCollationName()
Get the name of the default collation.
StringgetDefaultElementNamespace()
Get the default XPath namespace for elements and types.
StringgetDefaultFunctionNamespace()
Get the default function namespace
ExecutablegetExecutable()
Get the Executable, an object representing the compiled query and its environment.
FunctionLibrarygetFunctionLibrary()
Get the function library containing all the in-scope functions available in this static context (that is, the functions available in this query module).
XQueryFunctionLibrarygetGlobalFunctionLibrary()
Get the function library object that holds details of global functions
SlotManagergetGlobalStackFrameMap()
Get the stack frame map for global variables.
Iterator<GlobalVariableDefinition>getGlobalVariables()
Get all global variables declared in or imported into this module
ImportedFunctionLibrarygetImportedFunctionLibrary()
Get the function library object that holds details of imported functions
SetgetImportedSchemaNamespaces()
Get the set of imported schemas
StringgetLanguageVersion()
Get the language version supported
intgetLineNumber()
Get the line number of the expression within that container.
XQueryFunctionLibrarygetLocalFunctionLibrary()
Get the functions declared locally within this module
LocationMapgetLocationMap()
Get the LocationMap, an data structure used to identify the location of compiled expressions within the query source text.
URIgetLocationURI()
Get the location URI for a module
StringgetModuleNamespace()
Get the namespace of the current library module.
shortgetModuleNamespaceCode()
Get the namesapce code of the current library module.
IteratorgetModuleVariables()
Get global variables declared in this module
NamePoolgetNamePool()
Get the NamePool used for compiling expressions
NamespaceResolvergetNamespaceResolver()
Get a copy of the Namespace Context.
intgetRevalidationMode()
Get the revalidation mode.
StringgetSystemId()
Get the System ID for a module
QueryModulegetTopLevelModule()
Get the QueryModule for the top-level module.
StringgetURIForPrefix(String prefix)
Get the URI for a prefix.
UserFunctiongetUserDefinedFunction(String uri, String localName, int arity)
Get the function with a given name and arity.
StaticQueryContextgetUserQueryContext()
Get the StaticQueryContext object containing options set up by the user
booleanimportsNamespace(String uri)
Ask whether this module directly imports a particular namespace

This method is intended for internal use.

booleanimportsNamespaceIndirectly(String uri)
Test whether this module imports a particular namespace directly or indirectly

This method is intended for internal use.

booleanisAllowedBuiltInType(BuiltInAtomicType type)
Determine whether a built-in type is available in this context.
booleanisEmptyLeast()
Ask what is the option for where an empty sequence appears in the collation order, if not otherwise specified in the "order by" clause
booleanisImportedSchema(String namespace)
Get the schema for a given namespace, if it has been imported
booleanisInBackwardsCompatibleMode()
Determine whether Backwards Compatible Mode is used
booleanisInheritNamespaces()
Get the namespace inheritance mode
booleanisMainModule()
Ask whether this is a "main" module, in the sense of the XQuery language specification
booleanisPreserveBoundarySpace()
Ask whether the policy for boundary space is "preserve" or "strip"
booleanisPreserveNamespaces()
Get the namespace copy mode
voidissueWarning(String s, SourceLocator locator)
Issue a compile-time warning.
booleanisTopLevelModule()
Test whether this is a "top-level" module.
booleanisUpdating()
Ask whether the query is allowed to be updating
IteratoriterateImportedNamespaces()
Get an iterator over all the module namespaces that this module imports
voidlookForModuleCycles(Stack referees, int lineNumber)
Look for module cycles.
XPathContextmakeEarlyEvaluationContext()
Construct a dynamic context for early evaluation of constant subexpressions
static QueryModulemakeQueryModule(String baseURI, Executable executable, QueryModule importer, String query, String namespaceURI, boolean allowCycles)
Supporting method to load an imported library module.
booleanmayImportModule(String namespace)
Check whether this module is allowed to import a module with namespace N.
voidoptimizeGlobalFunctions()
Optimize the body of all global functions.
voidreportFatalError(XPathException err)
Report a fatal error in the query (via the registered ErrorListener)
voidsetBaseURI(String uri)
Set the base URI for a module
voidsetConstructionMode(int mode)
Set the construction mode for this module
voidsetDefaultCollationName(String collation)
Set the name of the default collation
voidsetDefaultElementNamespace(String uri)
Set the default element namespace as declared in the query prolog
voidsetDefaultFunctionNamespace(String uri)
Set the default function namespace
voidsetEmptyLeast(boolean least)
Set the option for where an empty sequence appears in the collation order, if not otherwise specified in the "order by" clause
voidsetExecutable(Executable executable)
Set the executable.
voidsetFunctionLibraryList(FunctionLibraryList functionLibrary)
Set the function library used for binding any function call appearing within the query module.
voidsetInheritNamespaces(boolean inherit)
Set the namespace inheritance mode
voidsetIsMainModule(boolean main)
Set whether this is a "Main" module, in the sense of the XQuery language specification
voidsetLocationURI(URI uri)
Set the location URI for a module
voidsetModuleNamespace(String uri)
Set the namespace for a library module.
voidsetPreserveBoundarySpace(boolean preserve)
Set the policy for preserving boundary space
voidsetPreserveNamespaces(boolean inherit)
Set the namespace copy mode
voidsetRevalidationMode(int mode)
Set the revalidation mode.
voidsetUpdating(boolean updating)
Set whether the query is allowed to be updating
voidtypeCheckGlobalVariables(List compiledVars)
Perform type checking on global variables.
voidundeclareNamespace()
Undeclare the most recently-declared active namespace.

Constructor Detail

QueryModule

public QueryModule(StaticQueryContext sqc)
Create a QueryModule for a main module, copying the data that has been set up in a StaticQueryContext object

Parameters: sqc the StaticQueryContext object from which this module is initialized

QueryModule

public QueryModule(Configuration config, QueryModule importer)
Create a QueryModule for a library module.

Parameters: config the Saxon configuration importer the module that imported this module. This may be null, in the case where the library module is being imported into an XSLT stylesheet

Method Detail

addImportedNamespace

public void addImportedNamespace(String uri)
Register that this module imports a particular module namespace

This method is intended for internal use.

Parameters: uri the URI of the imported namespace.

addImportedSchema

public void addImportedSchema(String targetNamespace, String baseURI, List locationURIs)
Add an imported schema to this static context. A query module can reference types in a schema provided two conditions are satisfied: the schema containing those types has been loaded into the Configuration, and the target namespace has been imported by this query module. This method achieves the second of these conditions. It does not cause the schema to be loaded.

Parameters: targetNamespace The target namespace of the schema to be added baseURI The base URI against which the locationURIs are to be absolutized locationURIs a list of strings containing the absolutized URIs of the "location hints" supplied for this schema

Since: 8.4

bindUnboundFunctionCalls

public void bindUnboundFunctionCalls()
Bind function calls that could not be bound when first encountered. These will either be forwards references to functions declared later in the same query module, or in modules that are being imported recursively, or errors.

This method is for internal use only.

Throws: net.sf.saxon.trans.XPathException if a function call refers to a function that has not been declared

bindUnboundVariables

public void bindUnboundVariables()
Bind unbound variables (these are typically variables that reference another module participating in a same-namespace cycle, since local forwards references are not allowed)

bindVariable

public Expression bindVariable(StructuredQName qName)
Bind a variable used in a query to the expression in which it is declared.

This method is provided for use by the XQuery parser, and it should not be called by the user of the API, or overridden, unless variables are to be declared using a mechanism other than the declareVariable method of this class.

Parameters: qName the name of the variable to be bound

Returns: a VariableReference object representing a reference to a variable on the abstract syntac rtee of the query.

checkForCircularities

public void checkForCircularities(List compiledVars, XQueryFunctionLibrary globalFunctionLibrary)
Check for circular definitions of global variables.

This method is intended for internal use

Parameters: compiledVars a list of GlobalVariableDefinition objects to be checked

checkImportedFunctionSignature

public void checkImportedFunctionSignature(XQueryFunction fd)
Check that all the types used in the signature of an imported function are available in the module of the caller of the function

Parameters: fd the declaration of the imported function

Throws: XPathException if an error is found

checkImportedType

public void checkImportedType(SequenceType importedType, Declaration declaration)
Check that a SequenceType used in the definition of an imported variable or function is available in the importing module

Parameters: importedType the type that is to be checked declaration the containing query or function definition

Throws: net.sf.saxon.trans.XPathException if an error is fonnd.

checkURIForPrefix

public String checkURIForPrefix(String prefix)
Get the URI for a prefix if there is one, return null if not. This method is used by the XQuery parser to resolve namespace prefixes.

This method is intended primarily for internal use.

Parameters: prefix The prefix. Supply "" to obtain the default namespace for elements and types.

Returns: the corresponding namespace URI, or null if the prefix has not been declared. If the prefix is "" and the default namespace is the non-namespace, return "".

declareActiveNamespace

public void declareActiveNamespace(String prefix, String uri)
Declare an active namespace, that is, a namespace which as well as affecting the static context of the query, will also be copied to the result tree when element constructors are evaluated. When searching for a prefix-URI binding, active namespaces are searched first, then passive namespaces. Active namespaces are later undeclared (in reverse sequence) using undeclareNamespace.

This method is intended for internal use only.

Parameters: prefix the namespace prefix uri the namespace URI

declareFunction

public void declareFunction(XQueryFunction function)
Register a user-defined XQuery function.

This method is intended for internal use only.

Parameters: function the function being declared

declarePrologNamespace

public void declarePrologNamespace(String prefix, String uri)
Register a namespace that is explicitly declared in the prolog of the query module.

Parameters: prefix The namespace prefix. Must not be null. uri The namespace URI. Must not be null. The value "" (zero-length string) is used to undeclare a namespace; it is not an error if there is no existing binding for the namespace prefix.

declareVariable

public void declareVariable(VariableDeclaration var)
Declare a global variable. A variable must normally be declared before an expression referring to it is compiled, but there are exceptions where a set of modules in the same namespace import each other cyclically. Global variables are normally declared in the Query Prolog, but they can also be predeclared using the Java API. All global variables are held in the QueryModule for the main module. The fact that a global variable is present therefore does not mean that it is visible: there are two additional conditions (a) the module namespace must be imported into the module where the reference appears, and (b) the declaration must not be in the same module and textually after the reference.

Note that the same VariableDeclaration object cannot be used with more than one query. This is because the VariableDeclaration is modified internally to hold a list of references to all the places where the variable is used.

Parameters: var the Variable declaration being declared

explainGlobalFunctions

public void explainGlobalFunctions(ExpressionPresenter out)
Output "explain" information about each declared function.

This method is intended primarily for internal use.

Parameters: out the expression presenter used to display the output

fixupGlobalFunctions

public void fixupGlobalFunctions()
Fixup all references to global functions. This method is called on completion of query parsing. Each XQueryFunction is required to bind all references to that function to the object representing the run-time executable code of the function.

This method is for internal use only. It is called only on the StaticQueryContext for the main query body (not for library modules).

fixupGlobalVariables

public List<GlobalVariableDefinition> fixupGlobalVariables(SlotManager globalVariableMap)
Fixup all references to global variables.

This method is for internal use by the Query Parser only.

Parameters: globalVariableMap a SlotManager that holds details of the assignment of slots to global variables.

Returns: a list containing the global variable definitions.

getActiveNamespaceCodes

public int[] getActiveNamespaceCodes()
Get an array containing the namespace codes of all active namespaces.

This method is for internal use only.

Returns: an array of namespace codes. A namespace code is an int that holds a prefix code in the top half and a uri code in the bottom half.

getAllImportedSchemata

public Map<String,HashSet<String>> getAllImportedSchemata()
For the top-level module only, get all the schema modules imported anywhere in the query.

Returns: a Map whose key is the target namespace of a set of schema documents, and whose value is a Set containing the absolutized location URIs ("hints") of the locations from which those schema documents were loaded, as strings.

getBaseURI

public String getBaseURI()
Get the base URI for a module

Returns: the base URI

getCollation

public StringCollator getCollation(String name)
Get a named collation.

Parameters: name The name of the required collation. Supply null to get the default collation.

Returns: the collation; or null if the required collation is not found.

getConfiguration

public Configuration getConfiguration()
Get the Saxon Configuration

Returns: the Saxon Configuration

getConstructionMode

public int getConstructionMode()
Get the current construction mode

Returns: one of STRIP, PRESERVE

getDecimalFormatManager

public DecimalFormatManager getDecimalFormatManager()
Get a DecimalFormatManager to resolve the names of decimal formats used in calls to the format-number() function.

Returns: the decimal format manager for this static context, or null if named decimal formats are not supported in this environment.

getDefaultCollationName

public String getDefaultCollationName()
Get the name of the default collation.

Returns: the name of the default collation; or the name of the codepoint collation if no default collation has been defined

getDefaultElementNamespace

public String getDefaultElementNamespace()
Get the default XPath namespace for elements and types. Note that this is not necessarily the default namespace declared in the query prolog; within an expression, it may change in response to namespace declarations on element constructors.

Returns: the default namespace, or NULL for the non-namespace

getDefaultFunctionNamespace

public String getDefaultFunctionNamespace()
Get the default function namespace

Returns: the default namespace for function names

getExecutable

public Executable getExecutable()
Get the Executable, an object representing the compiled query and its environment.

This method is intended for internal use only.

Returns: the Executable

getFunctionLibrary

public FunctionLibrary getFunctionLibrary()
Get the function library containing all the in-scope functions available in this static context (that is, the functions available in this query module).

This method is provided for use by advanced applications. The details of the interface are subject to change.

Returns: the FunctionLibrary used. For XQuery, this will always be a FunctionLibraryList.

See Also: FunctionLibraryList

getGlobalFunctionLibrary

public XQueryFunctionLibrary getGlobalFunctionLibrary()
Get the function library object that holds details of global functions

Returns: the library of global functions

getGlobalStackFrameMap

public SlotManager getGlobalStackFrameMap()
Get the stack frame map for global variables.

This method is intended for internal use.

Returns: the stack frame map (a SlotManager) for global variables.

getGlobalVariables

public Iterator<GlobalVariableDefinition> getGlobalVariables()
Get all global variables declared in or imported into this module

Returns: an iterator over the global variables

getImportedFunctionLibrary

public ImportedFunctionLibrary getImportedFunctionLibrary()
Get the function library object that holds details of imported functions

Returns: the library of imported functions

getImportedSchemaNamespaces

public Set getImportedSchemaNamespaces()
Get the set of imported schemas

Returns: a Set, the set of URIs representing the names of imported schemas

getLanguageVersion

public String getLanguageVersion()
Get the language version supported

Returns: the language version (currently "1.0" or "1.1")

Since: 9.2

getLineNumber

public int getLineNumber()
Get the line number of the expression within that container. Used to construct error messages. This method is provided to satisfy the StaticContext interface, but the value is meaningful only for XPath expressions within a document such as a stylesheet.

Returns: -1 always

getLocalFunctionLibrary

public XQueryFunctionLibrary getLocalFunctionLibrary()
Get the functions declared locally within this module

Returns: a FunctionLibrary object containing the function declarations

getLocationMap

public LocationMap getLocationMap()
Get the LocationMap, an data structure used to identify the location of compiled expressions within the query source text.

This method is intended for internal use only.

Returns: the LocationMap

getLocationURI

public URI getLocationURI()
Get the location URI for a module

Returns: the location URI

getModuleNamespace

public String getModuleNamespace()
Get the namespace of the current library module.

This method is intended primarily for internal use.

Returns: the module namespace, or null if this is a main module

getModuleNamespaceCode

public short getModuleNamespaceCode()
Get the namesapce code of the current library module.

This method is intended primarily for internal use.

Returns: the module namespace, or null if this is a main module

getModuleVariables

public Iterator getModuleVariables()
Get global variables declared in this module

Returns: an Iterator whose items are GlobalVariableDefinition objects

getNamePool

public NamePool getNamePool()
Get the NamePool used for compiling expressions

Returns: the name pool

getNamespaceResolver

public NamespaceResolver getNamespaceResolver()
Get a copy of the Namespace Context. This method is used internally by the query parser when a construct is encountered that needs to save the namespace context for use at run-time. Note that unlike other implementations of StaticContext, the state of the QueryModule changes as the query is parsed, with different namespaces in scope at different times. It's therefore necessary to compute the whole namespace context each time.

This method is for internal use only.

getRevalidationMode

public int getRevalidationMode()
Get the revalidation mode. This is used only if XQuery Updates are in use, in other cases the value is ignored.

Returns: the revalidation mode. This will be one of STRICT, LAX, or SKIP

getSystemId

public String getSystemId()
Get the System ID for a module

Returns: the location URI

getTopLevelModule

public QueryModule getTopLevelModule()
Get the QueryModule for the top-level module. This will normally be a main module, but in the case of saxon:import-query it will be the library module that is imported into the stylesheet

Returns: the StaticQueryContext object associated with the top level module

getURIForPrefix

public String getURIForPrefix(String prefix)
Get the URI for a prefix. This method is used by the XQuery parser to resolve namespace prefixes.

This method is intended primarily for internal use.

Parameters: prefix The prefix

Returns: the corresponding namespace URI

Throws: net.sf.saxon.trans.XPathException (with error code XPST0081) if the prefix has not been declared

getUserDefinedFunction

public UserFunction getUserDefinedFunction(String uri, String localName, int arity)
Get the function with a given name and arity. This method is provided so that XQuery functions can be called directly from a Java application. Note that there is no type checking or conversion of arguments when this is done: the arguments must be provided in exactly the form that the function signature declares them.

Parameters: uri the uri of the function name localName the local part of the function name arity the number of arguments.

Returns: the user-defined function

Since: 8.4

getUserQueryContext

public StaticQueryContext getUserQueryContext()
Get the StaticQueryContext object containing options set up by the user

Returns: the user-created StaticQueryContext object

importsNamespace

public boolean importsNamespace(String uri)
Ask whether this module directly imports a particular namespace

This method is intended for internal use.

Parameters: uri the URI of the possibly-imported namespace.

Returns: true if the schema for the namespace has been imported

importsNamespaceIndirectly

public boolean importsNamespaceIndirectly(String uri)
Test whether this module imports a particular namespace directly or indirectly

This method is intended for internal use.

Parameters: uri the URI of the possibly-imported namespace.

Returns: true if the schema for the namespace has been imported

isAllowedBuiltInType

public boolean isAllowedBuiltInType(BuiltInAtomicType type)
Determine whether a built-in type is available in this context. This method caters for differences between host languages as to which set of types are built in.

Parameters: type the supposedly built-in type. This will always be a type in the XS or XDT namespace.

Returns: true if this type can be used in this static context

isEmptyLeast

public boolean isEmptyLeast()
Ask what is the option for where an empty sequence appears in the collation order, if not otherwise specified in the "order by" clause

Returns: true if the empty sequence is considered less than any other value (the default), false if it is considered greater than any other value

isImportedSchema

public boolean isImportedSchema(String namespace)
Get the schema for a given namespace, if it has been imported

Parameters: namespace The namespace of the required schema. Supply "" for a no-namespace schema.

Returns: The schema if found, or null if not found.

Since: 8.4

isInBackwardsCompatibleMode

public boolean isInBackwardsCompatibleMode()
Determine whether Backwards Compatible Mode is used

Returns: false; XPath 1.0 compatibility mode is not supported in XQuery

Since: 8.4

isInheritNamespaces

public boolean isInheritNamespaces()
Get the namespace inheritance mode

Returns: true if namespaces are inherited, false if not

Since: 8.4

isMainModule

public boolean isMainModule()
Ask whether this is a "main" module, in the sense of the XQuery language specification

Returns: true if this is a main module, false if it is a library model

isPreserveBoundarySpace

public boolean isPreserveBoundarySpace()
Ask whether the policy for boundary space is "preserve" or "strip"

Returns: true if the policy is to preserve boundary space, false if it is to strip it

isPreserveNamespaces

public boolean isPreserveNamespaces()
Get the namespace copy mode

Returns: true if namespaces are preserved, false if not

issueWarning

public void issueWarning(String s, SourceLocator locator)
Issue a compile-time warning. This method is used during XQuery expression compilation to output warning conditions.

This method is intended for internal use only.

isTopLevelModule

public boolean isTopLevelModule()
Test whether this is a "top-level" module. This is true for a main module and also for a module directly imported into an XSLT stylesheet. It may also be true in future for independently-compiled modules

Returns: true if this is top-level module

isUpdating

public boolean isUpdating()
Ask whether the query is allowed to be updating

Returns: true if the query is allowed to use the XQuery Update facility

Since: 9.1

iterateImportedNamespaces

public Iterator iterateImportedNamespaces()
Get an iterator over all the module namespaces that this module imports

Returns: an iterator over the imported namespaces (delivered as strings)

lookForModuleCycles

public void lookForModuleCycles(Stack referees, int lineNumber)
Look for module cycles. This is a restriction introduced in the PR specification because of difficulties in defining the formal semantics.

[Definition: A module M1 directly depends on another module M2 (different from M1) if a variable or function declared in M1 depends on a variable or function declared in M2.] It is a static error [err:XQST0093] to import a module M1 if there exists a sequence of modules M1 ... Mi ... M1 such that each module directly depends on the next module in the sequence (informally, if M1 depends on itself through some chain of module dependencies.)

Parameters: referees a Stack containing the chain of module import references leading to this module lineNumber used for diagnostics

makeEarlyEvaluationContext

public XPathContext makeEarlyEvaluationContext()
Construct a dynamic context for early evaluation of constant subexpressions

Returns: a dynamic context object

makeQueryModule

public static QueryModule makeQueryModule(String baseURI, Executable executable, QueryModule importer, String query, String namespaceURI, boolean allowCycles)
Supporting method to load an imported library module. Used also by saxon:import-query in XSLT.

This method is intended for internal use only.

Parameters: baseURI The base URI and location URI of the module executable The Executable importer The importing query module (used to check for cycles). This is null when loading a query module from XSLT. query The text of the query, after decoding and normalizing line endings namespaceURI namespace of the query module to be loaded allowCycles True if cycles of module imports (disallowed by the spec) are to be permitted

Returns: The StaticQueryContext representing the loaded query module

Throws: XPathException

mayImportModule

public boolean mayImportModule(String namespace)
Check whether this module is allowed to import a module with namespace N. Note that before calling this we have already handled the exception case where a module imports another in the same namespace (this is the only case where cycles are allowed, though as a late change to the spec they are no longer useful, since they cannot depend on each other cyclically)

Parameters: namespace the namespace to be tested

Returns: true if the import is permitted

optimizeGlobalFunctions

public void optimizeGlobalFunctions()
Optimize the body of all global functions.

This method is for internal use only. It is called only on the StaticQueryContext for the main query body (not for library modules).

reportFatalError

public void reportFatalError(XPathException err)
Report a fatal error in the query (via the registered ErrorListener)

Parameters: err the error to be signalled

setBaseURI

public void setBaseURI(String uri)
Set the base URI for a module

Parameters: uri the base URI

setConstructionMode

public void setConstructionMode(int mode)
Set the construction mode for this module

Parameters: mode one of STRIP, PRESERVE

setDefaultCollationName

public void setDefaultCollationName(String collation)
Set the name of the default collation

Parameters: collation the URI of the default collation

setDefaultElementNamespace

public void setDefaultElementNamespace(String uri)
Set the default element namespace as declared in the query prolog

Parameters: uri the default namespace for elements and types

setDefaultFunctionNamespace

public void setDefaultFunctionNamespace(String uri)
Set the default function namespace

Parameters: uri the default namespace for functions

setEmptyLeast

public void setEmptyLeast(boolean least)
Set the option for where an empty sequence appears in the collation order, if not otherwise specified in the "order by" clause

Parameters: least true if the empty sequence is considered less than any other value (the default), false if it is considered greater than any other value

setExecutable

public void setExecutable(Executable executable)
Set the executable.

This method is intended for internal use only.

Parameters: executable the Executable

setFunctionLibraryList

public void setFunctionLibraryList(FunctionLibraryList functionLibrary)
Set the function library used for binding any function call appearing within the query module.

This method is available for use by advanced applications. The details of the FunctionLibrary interface are subject to change. Applications using this interface take responsibility for ensuring that the results conform to the constraints imposed by the XQuery language specification, for example that one function within a query module can call other functions defined in the same query module.

Parameters: functionLibrary the FunctionLibrary to be used. This will typically be a FunctionLibraryList; in most cases it will be a slightly modified copy of a FunctionLibraryList constructed by the system and obtained using the QueryModule method.

See Also: FunctionLibraryList

setInheritNamespaces

public void setInheritNamespaces(boolean inherit)
Set the namespace inheritance mode

Parameters: inherit true if namespaces are inherited, false if not

Since: 8.4

setIsMainModule

public void setIsMainModule(boolean main)
Set whether this is a "Main" module, in the sense of the XQuery language specification

Parameters: main true if this is a main module, false if it is a library module

setLocationURI

public void setLocationURI(URI uri)
Set the location URI for a module

Parameters: uri the location URI

setModuleNamespace

public void setModuleNamespace(String uri)
Set the namespace for a library module.

This method is for internal use only.

Parameters: uri the module namespace URI of the library module

setPreserveBoundarySpace

public void setPreserveBoundarySpace(boolean preserve)
Set the policy for preserving boundary space

Parameters: preserve true if boundary space is to be preserved, false if it is to be stripped

setPreserveNamespaces

public void setPreserveNamespaces(boolean inherit)
Set the namespace copy mode

Parameters: inherit true if namespaces are preserved, false if not

setRevalidationMode

public void setRevalidationMode(int mode)
Set the revalidation mode. This is used only if XQuery Updates are in use, in other cases the value is ignored.

Parameters: mode the revalidation mode. This must be one of STRICT, LAX, or SKIP

setUpdating

public void setUpdating(boolean updating)
Set whether the query is allowed to be updating

Parameters: updating true if the query may use the XQuery Update facility (requires Saxon-EE)

Since: 9.1

typeCheckGlobalVariables

public void typeCheckGlobalVariables(List compiledVars)
Perform type checking on global variables.

This method is intended for internal use

Parameters: compiledVars a list of GlobalVariableDefinition objects to be checked

undeclareNamespace

public void undeclareNamespace()
Undeclare the most recently-declared active namespace. This method is called when a namespace declaration goes out of scope (while processing an element end tag). It is NOT called when an XML 1.1-style namespace undeclaration is encountered.

This method is intended for internal use only.

See Also: QueryModule