Class QueryModule
- java.lang.Object
-
- net.sf.saxon.query.QueryModule
-
- All Implemented Interfaces:
StaticContext
- Direct Known Subclasses:
QueryLibrary
public class QueryModule extends java.lang.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
Constructors Constructor Description QueryModule(Configuration config, QueryModule importer)
Create a QueryModule for a library module.QueryModule(StaticQueryContext sqc)
Create a QueryModule for a main module, copying the data that has been set up in a StaticQueryContext object
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addImportedNamespace(NamespaceUri uri)
Register that this module imports a particular module namespacevoid
addImportedSchema(NamespaceUri targetNamespace, java.lang.String baseURI, java.util.List<java.lang.String> locationURIs)
Add an imported schema to this static context.void
bindUnboundFunctionCalls()
Bind function calls that could not be bound when first encountered.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)Expression
bindVariable(StructuredQName qName)
Bind a variable used in a query to the expression in which it is declared.void
checkForCircularities(java.util.List<GlobalVariable> compiledVars, XQueryFunctionLibrary globalFunctionLibrary)
Check for circular definitions of global variables.NamespaceUri
checkURIForPrefix(java.lang.String prefix)
Get the URI for a prefix if there is one, return null if not.void
declareActiveNamespace(java.lang.String prefix, NamespaceUri 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.void
declareFunction(XQueryFunction function)
Register a user-defined XQuery function.void
declarePrologNamespace(java.lang.String prefix, NamespaceUri uri)
Register a namespace that is explicitly declared in the prolog of the query module.void
declareVariable(GlobalVariable var)
Declare a global variable.void
explainGlobalFunctions(ExpressionPresenter out)
Output "explain" information about each declared function.void
fixupGlobalFunctions()
Fixup all references to global functions.java.util.List<GlobalVariable>
fixupGlobalVariables(SlotManager globalVariableMap)
Fixup all references to global variables.java.lang.Iterable<GlobalVariable>
getAllGlobalVariables()
Get all global variables declared anywhere in the queryBuiltInFunctionSet
getBuiltInFunctionSet()
CodeInjector
getCodeInjector()
Get the CodeInjector if one is in useConfiguration
getConfiguration()
Get the Saxon Configurationint
getConstructionMode()
Get the current construction modeLocation
getContainingLocation()
Get the LocationMap, an data structure used to identify the location of compiled expressions within the query source text.DecimalFormatManager
getDecimalFormatManager()
Get a DecimalFormatManager to resolve the names of decimal formats used in calls to the format-number() function.java.lang.String
getDefaultCollationName()
Get the name of the default collation.NamespaceUri
getDefaultElementNamespace()
Get the default XPath namespace for elements and types.NamespaceUri
getDefaultFunctionNamespace()
Get the default function namespaceExecutable
getExecutable()
Get the Executable, an object representing the compiled query and its environment.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).XQueryFunctionLibrary
getGlobalFunctionLibrary()
Get the function library object that holds details of global functionsSlotManager
getGlobalStackFrameMap()
Get the stack frame map for global variables.ImportedFunctionLibrary
getImportedFunctionLibrary()
Get the function library object that holds details of imported functionsjava.lang.Iterable<GlobalVariable>
getImportedGlobalVariables()
Get all global variables imported into this modulejava.util.Set<NamespaceUri>
getImportedSchemaNamespaces()
Get the set of imported schemasKeyManager
getKeyManager()
Get the KeyManager, containing definitions of keys available for use.NamespaceResolver
getLiveNamespaceResolver()
Return a NamespaceResolver which is "live" in the sense that, as the parse proceeds, it always uses the namespaces declarations in scope at the relevant timeXQueryFunctionLibrary
getLocalFunctionLibrary()
Get the functions declared locally within this modulejava.net.URI
getLocationURI()
Get the location URI for a moduleNamespaceUri
getModuleNamespace()
Get the namespace of the current library module.java.util.Iterator<GlobalVariable>
getModuleVariables()
Get global variables declared in this moduleNamespaceResolver
getNamespaceResolver()
Get a copy of the Namespace Context.OptimizerOptions
getOptimizerOptions()
Get the optimization options in use.PackageData
getPackageData()
Get package data.ItemType
getRequiredContextItemType()
Get the required type of the context item.int
getRevalidationMode()
Get the revalidation mode.java.lang.String
getStaticBaseURI()
Get the base URI for a modulejava.lang.String
getSystemId()
Get the System ID for a moduleQueryModule
getTopLevelModule()
Get the QueryModule for the top-level module.UnprefixedElementMatchingPolicy
getUnprefixedElementMatchingPolicy()
Get the matching policy for unprefixed element names in axis steps.UserFunction
getUserDefinedFunction(NamespaceUri uri, java.lang.String localName, int arity)
Get the function with a given name and arity.StaticQueryContext
getUserQueryContext()
Get the StaticQueryContext object containing options set up by the userint
getXPathVersion()
Get the XPath language level supported, as an integer (being the actual version number times ten).boolean
importsNamespace(NamespaceUri uri)
Ask whether this module directly imports a particular namespacevoid
initializeFunctionLibraries()
Reset function librariesboolean
isEmptyLeast()
Ask what is the option for where an empty sequence appears in the collation order, if not otherwise specified in the "order by" clauseboolean
isImportedSchema(NamespaceUri namespace)
Ask whether a given schema target namespace has been importedboolean
isInBackwardsCompatibleMode()
Determine whether Backwards Compatible Mode is usedboolean
isInheritNamespaces()
Get the namespace inheritance modeboolean
isMainModule()
Ask whether this is a "main" module, in the sense of the XQuery language specificationboolean
isPreserveBoundarySpace()
Ask whether the policy for boundary space is "preserve" or "strip"boolean
isPreserveNamespaces()
Get the namespace copy modeboolean
isSchemaAware()
Ask whether expressions compiled under this static context are schema-aware.void
issueWarning(java.lang.String s, java.lang.String errorCode, Location locator)
Issue a compile-time warning.boolean
isTopLevelModule()
Test whether this is a "top-level" module.boolean
isUpdating()
Ask whether the query module is allowed to be updatingXPathContext
makeEarlyEvaluationContext()
Construct a dynamic context for early evaluation of constant subexpressionsstatic QueryModule
makeQueryModule(java.lang.String baseURI, Executable executable, QueryModule importer, java.lang.String query, NamespaceUri namespaceURI)
Supporting method to load an imported library module.RetainedStaticContext
makeRetainedStaticContext()
Construct a RetainedStaticContext, which extracts information from this StaticContext to provide the subset of static context information that is potentially needed during expression evaluationboolean
mayImportModule(java.lang.String namespace)
Check whether this module is allowed to import a module with namespace N.void
optimizeGlobalFunctions()
Optimize the body of all global functions.void
reportStaticError(XmlProcessingError err)
Report a static error in the query (via the registered ErrorListener)void
reportStaticError(XPathException err)
Report a static error in the query (via the registered ErrorListener)ItemType
resolveTypeAlias(StructuredQName typeName)
Get type alias.void
setBaseURI(java.lang.String uri)
Set the base URI for a modulevoid
setConstructionMode(int mode)
Set the construction mode for this modulevoid
setDefaultCollationName(java.lang.String collation)
Set the name of the default collationvoid
setDefaultElementNamespace(NamespaceUri uri, boolean isFixedDefault)
Set the default element namespace as declared in the query prologvoid
setDefaultFunctionNamespace(NamespaceUri uri)
Set the default function namespacevoid
setEmptyLeast(boolean least)
Set the option for where an empty sequence appears in the collation order, if not otherwise specified in the "order by" clausevoid
setExecutable(Executable executable)
Set the executable.void
setInheritNamespaces(boolean inherit)
Set the namespace inheritance modevoid
setIsMainModule(boolean main)
Set whether this is a "Main" module, in the sense of the XQuery language specificationvoid
setLocationURI(java.net.URI uri)
Set the location URI for a modulevoid
setModuleNamespace(NamespaceUri uri)
Set the namespace for a library module.void
setPackageData(PackageData packageData)
Set the package data.void
setPreserveBoundarySpace(boolean preserve)
Set the policy for preserving boundary spacevoid
setPreserveNamespaces(boolean inherit)
Set the namespace copy modevoid
setRevalidationMode(int mode)
Set the revalidation mode.void
setUnprefixedElementMatchingPolicy(UnprefixedElementMatchingPolicy unprefixedElementMatchingPolicy)
Set the matching policy for unprefixed element names in axis steps.void
setXPathVersion(int languageLevel)
Set the XPath/XQuery language levelvoid
typeCheckGlobalVariables(java.util.List<GlobalVariable> compiledVars)
Perform type checking on global variables.void
undeclareNamespace()
Undeclare the most recently-declared active namespace.
-
-
-
Constructor Detail
-
QueryModule
public QueryModule(StaticQueryContext sqc) throws XPathException
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- Throws:
XPathException
- if information supplied is invalid
-
QueryModule
public QueryModule(Configuration config, QueryModule importer)
Create a QueryModule for a library module.- Parameters:
config
- the Saxon configurationimporter
- 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
-
makeQueryModule
public static QueryModule makeQueryModule(java.lang.String baseURI, Executable executable, QueryModule importer, java.lang.String query, NamespaceUri namespaceURI) throws XPathException
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. Must not be null.executable
- The Executableimporter
- 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 endingsnamespaceURI
- namespace of the query module to be loaded- Returns:
- The StaticQueryContext representing the loaded query module
- Throws:
XPathException
- if an error occurs
-
initializeFunctionLibraries
public void initializeFunctionLibraries()
Reset function libraries
-
getBuiltInFunctionSet
public BuiltInFunctionSet getBuiltInFunctionSet()
-
getConfiguration
public Configuration getConfiguration()
Get the Saxon Configuration- Specified by:
getConfiguration
in interfaceStaticContext
- Returns:
- the Saxon Configuration
-
getPackageData
public PackageData getPackageData()
Get package data. This is a small data object containing information about the unit of compilation, which in the case of XQuery is a query module- Specified by:
getPackageData
in interfaceStaticContext
- Returns:
- data about this query module
-
setPackageData
public void setPackageData(PackageData packageData)
Set the package data. This method is used when we want the QueryModule to share the same package data as another module: notably when fn:load-query-module creates a "dummy" main module to go with the dynamic library module- Parameters:
packageData
- the package information
-
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
-
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
-
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
-
mayImportModule
public boolean mayImportModule(java.lang.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
-
isSchemaAware
public boolean isSchemaAware()
Ask whether expressions compiled under this static context are schema-aware. They must be schema-aware if the expression is to handle typed (validated) nodes- Returns:
- true if expressions are schema-aware
-
getOptimizerOptions
public OptimizerOptions getOptimizerOptions()
Get the optimization options in use. By default these are taken from theConfiguration
- Specified by:
getOptimizerOptions
in interfaceStaticContext
- Returns:
- the optimization options in use
-
makeRetainedStaticContext
public RetainedStaticContext makeRetainedStaticContext()
Construct a RetainedStaticContext, which extracts information from this StaticContext to provide the subset of static context information that is potentially needed during expression evaluation- Specified by:
makeRetainedStaticContext
in interfaceStaticContext
- Returns:
- a RetainedStaticContext object: either a newly created one, or one that is reused from a previous invocation.
-
setInheritNamespaces
public void setInheritNamespaces(boolean inherit)
Set the namespace inheritance mode- Parameters:
inherit
- true if namespaces are inherited, false if not- Since:
- 8.4
-
isInheritNamespaces
public boolean isInheritNamespaces()
Get the namespace inheritance mode- Returns:
- true if namespaces are inherited, false if not
- Since:
- 8.4
-
setPreserveNamespaces
public void setPreserveNamespaces(boolean inherit)
Set the namespace copy mode- Parameters:
inherit
- true if namespaces are preserved, false if not
-
isPreserveNamespaces
public boolean isPreserveNamespaces()
Get the namespace copy mode- Returns:
- true if namespaces are preserved, false if not
-
setConstructionMode
public void setConstructionMode(int mode)
Set the construction mode for this module- Parameters:
mode
- one ofValidation.STRIP
,Validation.PRESERVE
-
getConstructionMode
public int getConstructionMode()
Get the current construction mode- Returns:
- one of
Validation.STRIP
,Validation.PRESERVE
-
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
-
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
-
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
-
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
-
getGlobalFunctionLibrary
public XQueryFunctionLibrary getGlobalFunctionLibrary()
Get the function library object that holds details of global functions- Returns:
- the library of global functions
-
getImportedFunctionLibrary
public ImportedFunctionLibrary getImportedFunctionLibrary()
Get the function library object that holds details of imported functions- Returns:
- the library of imported functions
-
addImportedNamespace
public void addImportedNamespace(NamespaceUri uri)
Register that this module imports a particular module namespaceThis method is intended for internal use.
- Parameters:
uri
- the URI of the imported namespace.
-
importsNamespace
public boolean importsNamespace(NamespaceUri uri)
Ask whether this module directly imports a particular namespaceThis 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
-
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
-
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
-
setExecutable
public void setExecutable(Executable executable)
Set the executable.This method is intended for internal use only.
- Parameters:
executable
- the Executable
-
getUserQueryContext
public StaticQueryContext getUserQueryContext()
Get the StaticQueryContext object containing options set up by the user- Returns:
- the user-created StaticQueryContext object
-
getContainingLocation
public Location getContainingLocation()
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.
- Specified by:
getContainingLocation
in interfaceStaticContext
- Returns:
- the LocationMap
-
setModuleNamespace
public void setModuleNamespace(NamespaceUri 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. Null is allowed only for a main module, not for a library module.
-
getModuleNamespace
public NamespaceUri 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
-
setLocationURI
public void setLocationURI(java.net.URI uri)
Set the location URI for a module- Parameters:
uri
- the location URI
-
getLocationURI
public java.net.URI getLocationURI()
Get the location URI for a module- Returns:
- the location URI
-
getSystemId
public java.lang.String getSystemId()
Get the System ID for a module- Specified by:
getSystemId
in interfaceStaticContext
- Returns:
- the location URI
-
setBaseURI
public void setBaseURI(java.lang.String uri)
Set the base URI for a module- Parameters:
uri
- the base URI
-
getStaticBaseURI
public java.lang.String getStaticBaseURI()
Get the base URI for a module- Specified by:
getStaticBaseURI
in interfaceStaticContext
- Returns:
- the base URI
-
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.
-
declareVariable
public void declareVariable(GlobalVariable var) throws XPathException
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- Throws:
XPathException
- if a static error is detected
-
getImportedGlobalVariables
public java.lang.Iterable<GlobalVariable> getImportedGlobalVariables()
Get all global variables imported into this module- Returns:
- a collection of global variables. In the case of a main module, this includes only variables imported into this module, it does not include variables declared within this module. In the case of a library module, it includes both locally declared and imported variables. Blame history.
-
getAllGlobalVariables
public java.lang.Iterable<GlobalVariable> getAllGlobalVariables()
Get all global variables declared anywhere in the query- Returns:
- a collection of global variables.
-
fixupGlobalVariables
public java.util.List<GlobalVariable> fixupGlobalVariables(SlotManager globalVariableMap) throws XPathException
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.
- Throws:
XPathException
- if compiling a global variable definition fails
-
getModuleVariables
public java.util.Iterator<GlobalVariable> getModuleVariables()
Get global variables declared in this module- Returns:
- an Iterator whose items are GlobalVariable objects
-
checkForCircularities
public void checkForCircularities(java.util.List<GlobalVariable> compiledVars, XQueryFunctionLibrary globalFunctionLibrary) throws XPathException
Check for circular definitions of global variables.This method is intended for internal use
- Parameters:
compiledVars
- a list ofGlobalVariable
objects to be checkedglobalFunctionLibrary
- the library of global functions- Throws:
XPathException
- if a circularity is found
-
typeCheckGlobalVariables
public void typeCheckGlobalVariables(java.util.List<GlobalVariable> compiledVars) throws XPathException
Perform type checking on global variables.This method is intended for internal use
- Parameters:
compiledVars
- a list ofGlobalVariable
objects to be checked- Throws:
XPathException
- if a type error occurs
-
bindVariable
public Expression bindVariable(StructuredQName qName) throws XPathException
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.
- Specified by:
bindVariable
in interfaceStaticContext
- 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.
- Throws:
XPathException
- if the variable cannot be bound (has not been declared)
-
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.
- Specified by:
getFunctionLibrary
in interfaceStaticContext
- Returns:
- the FunctionLibrary used. For XQuery, this will always be a FunctionLibraryList.
- See Also:
FunctionLibraryList
-
getLocalFunctionLibrary
public XQueryFunctionLibrary getLocalFunctionLibrary()
Get the functions declared locally within this module- Returns:
- a FunctionLibrary object containing the function declarations
-
declareFunction
public void declareFunction(XQueryFunction function) throws XPathException
Register a user-defined XQuery function.This method is intended for internal use only.
- Parameters:
function
- the function being declared- Throws:
XPathException
- if an error occurs, for example a duplicate function name
-
bindUnboundFunctionCalls
public void bindUnboundFunctionCalls() throws XPathException
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:
XPathException
- if a function call refers to a function that has not been declared
-
fixupGlobalFunctions
public void fixupGlobalFunctions() throws XPathException
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).
- Throws:
XPathException
- if an error occurs
-
optimizeGlobalFunctions
public void optimizeGlobalFunctions() throws XPathException
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).
- Throws:
XPathException
- if an error occurs during optimization
-
explainGlobalFunctions
public void explainGlobalFunctions(ExpressionPresenter out) throws XPathException
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- Throws:
XPathException
- if things go wrong, for example and I/O error
-
getUserDefinedFunction
public UserFunction getUserDefinedFunction(NamespaceUri uri, java.lang.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 namelocalName
- the local part of the function namearity
- the number of arguments.- Returns:
- the user-defined function, or null if no function with the given name and arity can be located
- Since:
- 8.4
-
bindUnboundVariables
public void bindUnboundVariables() throws XPathException
Bind unbound variables (these are typically variables that reference another module participating in a same-namespace cycle, since local forwards references are not allowed)- Throws:
XPathException
- if an error occurs, for example if the variable reference cannot be resolved or if the variable is private
-
addImportedSchema
public void addImportedSchema(NamespaceUri targetNamespace, java.lang.String baseURI, java.util.List<java.lang.String> 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 addedbaseURI
- The base URI against which the locationURIs are to be absolutizedlocationURIs
- a list of strings containing the absolutized URIs of the "location hints" supplied for this schema- Since:
- 8.4
-
isImportedSchema
public boolean isImportedSchema(NamespaceUri namespace)
Ask whether a given schema target namespace has been imported- Specified by:
isImportedSchema
in interfaceStaticContext
- 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
-
getImportedSchemaNamespaces
public java.util.Set<NamespaceUri> getImportedSchemaNamespaces()
Get the set of imported schemas- Specified by:
getImportedSchemaNamespaces
in interfaceStaticContext
- Returns:
- a Set, the set of URIs representing the names of imported schemas
-
reportStaticError
public void reportStaticError(XPathException err)
Report a static error in the query (via the registered ErrorListener)- Parameters:
err
- the error to be signalled
-
reportStaticError
public void reportStaticError(XmlProcessingError err)
Report a static error in the query (via the registered ErrorListener)- Parameters:
err
- the error to be signalled
-
makeEarlyEvaluationContext
public XPathContext makeEarlyEvaluationContext()
Construct a dynamic context for early evaluation of constant subexpressions- Specified by:
makeEarlyEvaluationContext
in interfaceStaticContext
- Returns:
- a dynamic context object
-
getDefaultCollationName
public java.lang.String getDefaultCollationName()
Get the name of the default collation.- Specified by:
getDefaultCollationName
in interfaceStaticContext
- Returns:
- the name of the default collation; or the name of the codepoint collation if no default collation has been defined
-
setDefaultCollationName
public void setDefaultCollationName(java.lang.String collation)
Set the name of the default collation- Parameters:
collation
- the URI of the default collation
-
declarePrologNamespace
public void declarePrologNamespace(java.lang.String prefix, NamespaceUri uri) throws XPathException
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.- Throws:
XPathException
- if the declaration is invalid
-
declareActiveNamespace
public void declareActiveNamespace(java.lang.String prefix, NamespaceUri 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) usingundeclareNamespace()
.This method is intended for internal use only.
- Parameters:
prefix
- the namespace prefixuri
- the namespace URI
-
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.
-
getLiveNamespaceResolver
public NamespaceResolver getLiveNamespaceResolver()
Return a NamespaceResolver which is "live" in the sense that, as the parse proceeds, it always uses the namespaces declarations in scope at the relevant time- Returns:
- a live NamespaceResolver
-
getUnprefixedElementMatchingPolicy
public UnprefixedElementMatchingPolicy getUnprefixedElementMatchingPolicy()
Get the matching policy for unprefixed element names in axis steps. This is a Saxon extension. The value can be any ofUnprefixedElementMatchingPolicy.DEFAULT_NAMESPACE
(the default), which uses the value ofgetDefaultElementNamespace()
, orUnprefixedElementMatchingPolicy.DEFAULT_NAMESPACE_OR_NONE
, which matches both the namespace given ingetDefaultElementNamespace()
and the null namespace, orUnprefixedElementMatchingPolicy.ANY_NAMESPACE
, which matches any namespace (that is, it matches by local name only).- Specified by:
getUnprefixedElementMatchingPolicy
in interfaceStaticContext
- Returns:
- the policy for matching unprefixed element names
-
setUnprefixedElementMatchingPolicy
public void setUnprefixedElementMatchingPolicy(UnprefixedElementMatchingPolicy unprefixedElementMatchingPolicy)
Set the matching policy for unprefixed element names in axis steps. This is a Saxon extension. The value can be any ofUnprefixedElementMatchingPolicy.DEFAULT_NAMESPACE
(the default), which uses the value ofgetDefaultElementNamespace()
, orUnprefixedElementMatchingPolicy.DEFAULT_NAMESPACE_OR_NONE
, which matches both the namespace given ingetDefaultElementNamespace()
and the null namespace, orUnprefixedElementMatchingPolicy.ANY_NAMESPACE
, which matches any namespace (that is, it matches by local name only).
-
checkURIForPrefix
public NamespaceUri checkURIForPrefix(java.lang.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 "".
-
getDefaultElementNamespace
public NamespaceUri 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.- Specified by:
getDefaultElementNamespace
in interfaceStaticContext
- Returns:
- the default namespace, or
NamespaceConstant.NULL
for the non-namespace
-
setDefaultElementNamespace
public void setDefaultElementNamespace(NamespaceUri uri, boolean isFixedDefault)
Set the default element namespace as declared in the query prolog- Parameters:
uri
- the default namespace for elements and types
-
getDefaultFunctionNamespace
public NamespaceUri getDefaultFunctionNamespace()
Get the default function namespace- Specified by:
getDefaultFunctionNamespace
in interfaceStaticContext
- Returns:
- the default namespace for function names
-
setDefaultFunctionNamespace
public void setDefaultFunctionNamespace(NamespaceUri uri)
Set the default function namespace- Parameters:
uri
- the default namespace for functions
-
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 ofValidation.STRICT
,Validation.LAX
, orValidation.SKIP
-
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
Validation.STRICT
,Validation.LAX
, orValidation.SKIP
-
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.
- Specified by:
getNamespaceResolver
in interfaceStaticContext
- Returns:
- a namespace resolver.
-
getRequiredContextItemType
public ItemType getRequiredContextItemType()
Get the required type of the context item. If no type has been explicitly declared for the context item, an instance of AnyItemType (representing the type item()) is returned.- Specified by:
getRequiredContextItemType
in interfaceStaticContext
- Returns:
- the required type of the context item. Note that this is the same for all modules.
- Since:
- 9.3
-
getDecimalFormatManager
public DecimalFormatManager getDecimalFormatManager()
Get a DecimalFormatManager to resolve the names of decimal formats used in calls to the format-number() function.- Specified by:
getDecimalFormatManager
in interfaceStaticContext
- Returns:
- the decimal format manager for this static context, or null if named decimal formats are not supported in this environment.
-
issueWarning
public void issueWarning(java.lang.String s, java.lang.String errorCode, Location 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.
- Specified by:
issueWarning
in interfaceStaticContext
- Parameters:
s
- The warning message. This should not contain any prefix such as "Warning".errorCode
- Error code identifying the warning conditionlocator
- the location of the construct in question. May be null.
-
isInBackwardsCompatibleMode
public boolean isInBackwardsCompatibleMode()
Determine whether Backwards Compatible Mode is used- Specified by:
isInBackwardsCompatibleMode
in interfaceStaticContext
- Returns:
- false; XPath 1.0 compatibility mode is not supported in XQuery
- Since:
- 8.4
-
isUpdating
public boolean isUpdating()
Ask whether the query module is allowed to be updating- Returns:
- true if the query module is allowed to use the XQuery Update facility
- Since:
- 9.1
-
setXPathVersion
public void setXPathVersion(int languageLevel)
Set the XPath/XQuery language level- Parameters:
languageLevel
- 31 for 3.1, 40 for 4.0.
-
getXPathVersion
public int getXPathVersion()
Get the XPath language level supported, as an integer (being the actual version number times ten).- Specified by:
getXPathVersion
in interfaceStaticContext
- Returns:
- the XPath language level; the return value will be 31 for XPath 3.1 and 40 for XPath 4.0
- Since:
- 9.7. In Saxon 9.9 the only value supported for XQuery is 3.1. Saxon 11 also supports 4.0 (identified as integer 40).
-
getCodeInjector
public CodeInjector getCodeInjector()
Get the CodeInjector if one is in use- Returns:
- the code injector if there is one
-
getKeyManager
public KeyManager getKeyManager()
Get the KeyManager, containing definitions of keys available for use.- Specified by:
getKeyManager
in interfaceStaticContext
- Returns:
- the KeyManager. This is used to resolve key names, both explicit calls on key() used in XSLT, and system-generated calls on key() which may also appear in XQuery and XPath
-
resolveTypeAlias
public ItemType resolveTypeAlias(StructuredQName typeName)
Get type alias. This is a Saxon extension. A type alias is a QName which can be used as a shorthand for an itemtype, using the syntax ~typename anywhere that an item type is permitted.- Specified by:
resolveTypeAlias
in interfaceStaticContext
- Parameters:
typeName
- the name of the type alias- Returns:
- the corresponding item type, if the name is recognised; otherwise null.
-
-