Class StaticQueryContext
- All Implemented Interfaces:
StaticContext
- Since:
- 8.4
-
Constructor Summary
ConstructorsConstructorDescriptionStaticQueryContext
(Configuration config) Create a StaticQueryContext using a given Configuration.StaticQueryContext
(Configuration config, StaticQueryContext importer) Create a StaticQueryContext for a library module. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Register that this module imports a particular module namespacevoid
addImportedSchema
(String targetNamespace) Add an imported schema to this static context.void
Bind function calls that could not be bound when first encountered.void
Bind unbound variables (these are typically variables that reference another module participating in a same-namespace cycle, since local forwards references are not allowedbindVariable
(int fingerprint) Bind a variable used in a query to the expression in which it is declared.buildDocument
(Source source) Convenience method for building Saxon's internal representation of a source XML document.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 modulecheckURIForPrefix
(String prefix) Get the URI for a prefix if there is one, return null if not.void
Clear all the declared passive namespaces, except for the standard ones (xml, saxon, etc)compileQuery
(InputStream source, String encoding) Prepare an XQuery query for subsequent evaluation.compileQuery
(Reader source) Prepare an XQuery query for subsequent evaluation.compileQuery
(String query) Prepare an XQuery query for subsequent evaluation.copy()
Make a copy of this StaticQueryContext.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.void
declareCollation
(String name, Comparator comparator) Declare a named collation.void
Set the default collation.void
declareFunction
(XQueryFunction function) Register a user-defined XQuery function.void
declarePassiveNamespace
(String prefix, String uri, boolean explicit) Declare a namespace whose prefix can be used in expressions.void
Declare a global variable.void
Output "explain" information about each declared function.void
Produce "explain" output for all global variables.void
Fixup all references to global functions.fixupGlobalVariables
(SlotManager globalVariableMap) Fixup all references to global variables.int[]
Get an array containing the namespace codes of all active namespaces.Get a HashMap that maps all registered collations to Comparators.Get the Base URI of the query, for resolving any relative URI's used in the expression.getCollation
(String name) Get a named collation.Get the Configuration optionsint
Get the current validation modeGet the name of the default collation.short
Get the default XPath namespace, as a namespace URI code that can be looked up in the NamePoolGet the default function namespaceGet the ErrorListener in use for this static contextGet the Executable, an object representing the compiled query and its environment.Get the external namespace resolver that has been registered using setExternalNamespaceResolver(), if any.Get the function library containing all the in-scope functions available in this static context (that is, the functions available in this query module).Get the stack frame map for global variables.Get the set of imported schemasint
Get the line number of the expression within that container.Get the functions declared locally within this moduleGet the LocationMap, an data structure used to identify the location of compiled expressions within the query source text.Get the location URI for a moduleGet the namespace of the current library module.short
Get the namesapce code of the current library module.Get the user-defined ModuleURIResolver for resolving URIs used in "import module" declarations in the XQuery prolog; returns null if none has been explicitly set either on the StaticQueryContext or on the Configuration.Get global variables declared in this moduleGet the NamePool used for compiling expressionsGet a copy of the Namespace Context.Get the required type of the context item.Get the stack frame map for local variables in the "main" query expression.Get the system ID of the container of the expression.Get the Static Query Context for the top-level module.getURIForPrefix
(String prefix) Get the URI for a prefix.getUserDefinedFunction
(String uri, String localName, int arity) Get the function with a given name and arity.boolean
importsNamespace
(String uri) Test whether this module directly imports a particular namespaceboolean
Test whether this module imports a particular namespace directly or indirectlyboolean
Determine whether a built-in type is available in this context.boolean
isImportedSchema
(String namespace) Get the schema for a given namespace, if it has been importedboolean
Determine whether Backwards Compatible Mode is usedboolean
Get the namespace inheritance modeboolean
Test whether this is a "main" module, in the sense of the XQuery language specificationboolean
Get the namespace copy modevoid
issueWarning
(String s, SourceLocator locator) Issue a compile-time warning.boolean
Test whether this is a "top-level" module.Get an iterator over all the module namespaces that this module importsConstruct a dynamic context for early evaluation of constant subexpressionsstatic StaticQueryContext
makeStaticQueryContext
(String baseURI, Executable executable, StaticQueryContext importer, String query, String namespaceURI) Supporting method to load a query module.boolean
Check whether this module is allowed to import a module with namespace N.void
Report a fatal error in the query (via the registered ErrorListener)void
reset()
Reset the state of this StaticQueryContext to an uninitialized statevoid
setBaseURI
(String baseURI) Set the Base URI of the queryvoid
setConfiguration
(Configuration config) Deprecated.This method serves no purpose, since it is not possible to change the configuration once the StaticQueryContext has been initialized.void
setConstructionMode
(int mode) Set the construction mode for this modulevoid
Set the default element namespacevoid
setDefaultFunctionNamespace
(String defaultFunctionNamespace) Set the default function namespacevoid
setErrorListener
(ErrorListener listener) Set the ErrorListener to be used to report compile-time errors in a query.void
setExecutable
(Executable executable) Set the executable.void
Set an external namespace resolver.void
setFunctionLibraryList
(FunctionLibraryList functionLibrary) Set the function library used for binding any function call appearing within the query module.void
setInheritNamespaces
(boolean inherit) Set the namespace inheritance modevoid
setLocationURI
(String uri) Set the location URI for a modulevoid
setModuleNamespace
(String uri) Set the namespace for a library module.void
setModuleURIResolver
(ModuleURIResolver resolver) Set a user-defined ModuleURIResolver for resolving URIs used in "import module" declarations in the XQuery prolog.void
setPreserveNamespaces
(boolean inherit) Set the namespace copy modevoid
Declare the static type of the context item.void
typeCheckGlobalVariables
(List compiledVars) Get references to undeclared variables.void
Undeclare the most recently-declared active namespace.
-
Constructor Details
-
StaticQueryContext
Create a StaticQueryContext using a given Configuration. This creates a StaticQueryContext for a main module (that is, a module that is not a library module).- Since:
- 8.4
-
StaticQueryContext
Create a StaticQueryContext for a library module.- Parameters:
importer
- the module that imported this module. This may be null, in which case the library module is treated as a "top-level" library module.
-
-
Method Details
-
reset
public void reset()Reset the state of this StaticQueryContext to an uninitialized state- Since:
- 8.4
-
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 -
isMainModule
public boolean isMainModule()Test whether this is a "main" module, in the sense of the XQuery language specification -
mayImport
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 (the only case where cycles are allowed) -
getGlobalFunctionLibrary
-
getImportedFunctionLibrary
-
addImportedNamespace
Register that this module imports a particular module namespace -
importsNamespace
Test whether this module directly imports a particular namespace -
importsNamespaceIndirectly
Test whether this module imports a particular namespace directly or indirectly -
iterateImportedNamespaces
Get an iterator over all the module namespaces that this module imports -
getTopLevelModule
Get the Static Query Context 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 -
copy
Make a copy of this StaticQueryContext. The StaticQueryContext that is constructed by a user application and passed to Saxon when a query is compiled should not be modified by the query compiler. Saxon therefore makes a copy of the StaticQueryContext and uses this copy internally, to capture any changes to the StaticQueryContext defined in the query prolog.- Returns:
- a copy of this StaticQueryContext
-
setConfiguration
Deprecated.This method serves no purpose, since it is not possible to change the configuration once the StaticQueryContext has been initialized.Set the Configuration options- Throws:
IllegalArgumentException
- if the configuration supplied is different from the existing configuration- Since:
- 8.4
-
getConfiguration
Get the Configuration options- Specified by:
getConfiguration
in interfaceStaticContext
- Since:
- 8.4
-
makeEarlyEvaluationContext
Construct a dynamic context for early evaluation of constant subexpressions- Specified by:
makeEarlyEvaluationContext
in interfaceStaticContext
-
buildDocument
Convenience method for building Saxon's internal representation of a source XML document. The document will be built using the default NamePool, which means that any process that uses it must also use the default NamePool.- Parameters:
source
- Any javax.xml.transform.Source object representing the document against which queries will be executed. Note that a SaxonDocumentInfo
(indeed anyNodeInfo
) can be used as a Source. To use a third-party DOM Document as a source, create an instance ofDOMSource
to wrap it.For additional control over the way in which the source document is processed, supply an
AugmentedSource
object and set appropriate options on the object.- Returns:
- the DocumentInfo representing the root node of the resulting document object.
- Throws:
XPathException
- Since:
- 8.4
-
compileQuery
Prepare an XQuery query for subsequent evaluation. The source text of the query is supplied as a String. The base URI of the query is taken from the static context, and defaults to the current working directory.- Parameters:
query
- The XQuery query to be evaluated, supplied as a string.- Returns:
- an XQueryExpression object representing the prepared expression
- Throws:
XPathException
- if the syntax of the expression is wrong, or if it references namespaces, variables, or functions that have not been declared, or contains other static errors.- Since:
- 8.4
-
compileQuery
Prepare an XQuery query for subsequent evaluation. The Query is supplied in the form of a Reader. The base URI of the query is taken from the static context, and defaults to the current working directory.- Parameters:
source
- A Reader giving access to the text of the XQuery query to be compiled.- Returns:
- an XPathExpression object representing the prepared expression.
- Throws:
XPathException
- if the syntax of the expression is wrong, or if it references namespaces, variables, or functions that have not been declared, or any other static error is reported.IOException
- if a failure occurs reading the supplied input.- Since:
- 8.4
-
compileQuery
public XQueryExpression compileQuery(InputStream source, String encoding) throws XPathException, IOException Prepare an XQuery query for subsequent evaluation. The Query is supplied in the form of a InputStream, with an optional encoding. If the encoding is not specified, the query parser attempts to obtain the encoding by inspecting the input stream: it looks specifically for a byte order mark, and for the encoding option in the version declaration of an XQuery prolog. The encoding defaults to UTF-8. The base URI of the query is taken from the static context, and defaults to the current working directory.- Parameters:
source
- An InputStream giving access to the text of the XQuery query to be compiled, as a stream of octetsencoding
- The encoding used to translate characters to octets in the query source. The parameter may be null: in this case the query parser attempts to infer the encoding by inspecting the source, and if that fails, it assumes UTF-8 encoding- Returns:
- an XPathExpression object representing the prepared expression.
- Throws:
XPathException
- if the syntax of the expression is wrong, or if it references namespaces, variables, or functions that have not been declared, or any other static error is reported.IOException
- if a failure occurs reading the supplied input.- Since:
- 8.5
-
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
Set the executable. This method is intended for internal use only.- Parameters:
executable
- the Executable
-
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.- Specified by:
getLocationMap
in interfaceStaticContext
- Returns:
- the LocationMap
-
declarePassiveNamespace
Declare a namespace whose prefix can be used in expressions. This is a passive namespace, it won't be copied into the result tree. Passive namespaces are never undeclared, and active namespaces override them.- 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.explicit
- This parameter is set to true when Saxon calls the method internally to define a namespace declared within the query prolog. It should normally be set to false in the case of a call from a user application.- Throws:
StaticError
- Since:
- 8.4
-
declareActiveNamespace
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 may be undeclared (in reverse sequence) usingundeclareNamespace()
. This method is intended for internal use only. -
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:
-
clearPassiveNamespaces
public void clearPassiveNamespaces()Clear all the declared passive namespaces, except for the standard ones (xml, saxon, etc)- Since:
- 8.4
-
setExternalNamespaceResolver
Set an external namespace resolver. If a namespace prefix cannot be resolved using any other mechanism, then as a last resort the external namespace resolver is called to obtain a URI for the given prefix.Note that the external namespace resolver is used only for namespace prefixes that are resolved at compile time. Where namespace prefixes are resolved at run-time (which happens very rarely with XQuery: the only case is to resolve the computed name used in a computed element or attribute constructor), the external namespace resolver is not invoked.
Although the supplied object must implement the NamespaceResolver interface, the only method actually used is the method
NamespaceResolver.getURIForPrefix(String, boolean)
. Other methods may throw an UnsupportedOperationException. -
getExternalNamespaceResolver
Get the external namespace resolver that has been registered using setExternalNamespaceResolver(), if any. -
getURIForPrefix
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.- Specified by:
getURIForPrefix
in interfaceStaticContext
- Parameters:
prefix
- The prefix- Returns:
- the corresponding namespace URI
- Throws:
XPathException
- if the prefix has not been declared
-
checkURIForPrefix
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.- 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 "".
-
getActiveNamespaceCodes
public int[] getActiveNamespaceCodes()Get an array containing the namespace codes of all active namespaces. This method is for internal use only. -
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. This method is for internal use only.- Specified by:
getNamespaceResolver
in interfaceStaticContext
- Returns:
- a namespace resolver.
-
getDefaultFunctionNamespace
Get the default function namespace- Specified by:
getDefaultFunctionNamespace
in interfaceStaticContext
- Returns:
- the default function namespace (defaults to the fn: namespace)
- Since:
- 8.4
-
setDefaultFunctionNamespace
Set the default function namespace- Parameters:
defaultFunctionNamespace
- The namespace to be used for unprefixed function calls- Since:
- 8.4
-
setDefaultElementNamespace
Set the default element namespace- Throws:
StaticError
- Since:
- 8.4
-
getDefaultElementNamespace
public short getDefaultElementNamespace()Get the default XPath namespace, as a namespace URI code that can be looked up in the NamePool- Specified by:
getDefaultElementNamespace
in interfaceStaticContext
- Since:
- 8.4
-
setModuleNamespace
Set the namespace for a library module. This method is for internal use only. -
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
-
setLocationURI
Set the location URI for a module -
getLocationURI
Get the location URI for a module -
setModuleURIResolver
Set a user-defined ModuleURIResolver for resolving URIs used in "import module" declarations in the XQuery prolog. This will be used for resolving URIs in XQuery "import module" declarations, overriding any ModuleURIResolver that was specified as part of the configuration. -
getModuleURIResolver
Get the user-defined ModuleURIResolver for resolving URIs used in "import module" declarations in the XQuery prolog; returns null if none has been explicitly set either on the StaticQueryContext or on the Configuration. -
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- Since:
- 8.4
-
isPreserveNamespaces
public boolean isPreserveNamespaces()Get the namespace copy mode- Returns:
- true if namespaces are preserved, false if not
- Since:
- 8.4
-
declareCollation
Declare a named collation. Collations are only available in a query if this method has been called externally to declare the collation and associate it with an implementation, in the form of a Java Comparator. The default collation is the Unicode codepoint collation, unless otherwise specified.- Parameters:
name
- The name of the collation (technically, a URI)comparator
- The Java Comparator used to implement the collating sequence- Since:
- 8.4
-
declareDefaultCollation
Set the default collation.- Parameters:
name
- The collation name, as specified in the query prolog. The name is not validated until it is used.- Since:
- 8.4. Changed in 8.6 so it no longer validates the collation name: this is because the base URI is not necessarily known at the point where the default collation is declared.
-
getCollation
Get a named collation.- Specified by:
getCollation
in interfaceStaticContext
- Parameters:
name
- the name of the collation, as an absolute URI- Returns:
- the collation identified by the given name, as set previously using declareCollation. If no collation with this name has been declared, the method calls the CollationURIResolver to locate a collation with this name. Return null if no collation with this name is found.
- Since:
- 8.4
-
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. The name is returned in the form it was specified; that is, it is not yet resolved against the base URI. (This is because the base URI declaration can follow the default collation declaration in the query prolog.) If no default collation has been specified, the "default default" (that is, the Unicode codepoint collation) is returned.
- Since:
- 8.4
-
getAllCollations
Get a HashMap that maps all registered collations to Comparators. Note that this returns a snapshot copy of the data held by the static context. This method is provided for internal use by the query processor. This method is intended for internal use. -
setRequiredContextItemType
Declare the static type of the context item. If this type is declared, and if a context item is supplied when the query is invoked, then the context item must conform to this type (no type conversion will take place to force it into this type).- Parameters:
type
- the required context item type
-
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. -
getGlobalStackFrameMap
Get the stack frame map for global variables. This method is intended for internal use. -
declareVariable
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 this API. All global variables are held in the StaticQueryContext 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 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 VariableDeclation 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.
- Throws:
StaticError
- Since:
- 8.4
-
fixupGlobalVariables
Fixup all references to global variables. This method is for internal use by the Query Parser only.- Throws:
StaticError
-
getModuleVariables
Get global variables declared in this module- Returns:
- an Iterator whose items are GlobalVariableDefinition objects
-
typeCheckGlobalVariables
Get references to undeclared variables. return a list of XPathException objects, one for each undeclared variable- Throws:
StaticError
-
explainGlobalVariables
public void explainGlobalVariables()Produce "explain" output for all global variables. This method is intended primarily for internal use. -
getStackFrameMap
Get the stack frame map for local variables in the "main" query expression. This method is intended for internal use only. -
getNamePool
Get the NamePool used for compiling expressions- Specified by:
getNamePool
in interfaceStaticContext
- Since:
- 8.4
-
issueWarning
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
-
setBaseURI
Set the Base URI of the query- Since:
- 8.4
-
getSystemId
Get the system ID of the container of the expression. Used to construct error messages. Note that the systemID and the Base URI are currently identical, but they might be distinguished in the future.- Specified by:
getSystemId
in interfaceStaticContext
- Returns:
- the Base URI
- Since:
- 8.4
-
getBaseURI
Get the Base URI of the query, for resolving any relative URI's used in the expression. Note that the systemID and the Base URI are currently identical, but they might be distinguished in the future. Used by the document() function.- Specified by:
getBaseURI
in interfaceStaticContext
- Returns:
- the base URI of the query
- Since:
- 8.4
-
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.- Specified by:
getLineNumber
in interfaceStaticContext
- Returns:
- -1 always
-
bindVariable
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:
fingerprint
- the name of the variable- Returns:
- a VariableReference representing the variable reference, suitably initialized to refer to the corresponding variable declaration
- Throws:
StaticError
-
setFunctionLibraryList
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 thegetFunctionLibrary()
method.- See Also:
-
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:
-
getLocalFunctionLibrary
Get the functions declared locally within this module -
declareFunction
Register a user-defined XQuery function. This method is intended for internal use only.- Throws:
StaticError
-
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:
StaticError
- if a function call refers to a function that has not been declaredXPathException
-
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.- Throws:
XPathException
-
explainGlobalFunctions
Output "explain" information about each declared function. This method is intended primarily for internal use.- Throws:
XPathException
-
getUserDefinedFunction
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.- Since:
- 8.4
-
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- Throws:
XPathException
-
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
-
addImportedSchema
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- Since:
- 8.4
-
isImportedSchema
Get the schema for a given namespace, if it 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
Get the set of imported schemas- Specified by:
getImportedSchemaNamespaces
in interfaceStaticContext
- Returns:
- a Set, the set of URIs representing the names of imported schemas
-
isAllowedBuiltInType
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.- Specified by:
isAllowedBuiltInType
in interfaceStaticContext
- 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
-
setConstructionMode
public void setConstructionMode(int mode) Set the construction mode for this module- Parameters:
mode
- one ofValidation.STRIP
,Validation.PRESERVE
- Since:
- 8.4
-
getConstructionMode
public int getConstructionMode()Get the current validation mode- Returns:
- one of
Validation.STRIP
,Validation.PRESERVE
- Since:
- 8.4
-
makeStaticQueryContext
public static StaticQueryContext makeStaticQueryContext(String baseURI, Executable executable, StaticQueryContext importer, String query, String namespaceURI) throws StaticError Supporting method to load a query 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 moduleexecutable
- 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:
StaticError
-
setErrorListener
Set the ErrorListener to be used to report compile-time errors in a query. This will also be the default for the run-time error listener used to report dynamic errors -
getErrorListener
Get the ErrorListener in use for this static context -
reportFatalError
Report a fatal error in the query (via the registered ErrorListener) -
checkImportedType
public void checkImportedType(SequenceType importedType, Declaration declaration) throws StaticError Check that a SequenceType used in the definition of an imported variable or function is available in the importing module- Throws:
StaticError
-