net.sf.saxon.query
public class QueryModule extends Object implements StaticContext
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 | |
---|---|
void | addImportedNamespace(String uri)
Register that this module imports a particular module namespace
This method is intended for internal use. |
void | addImportedSchema(String targetNamespace, String baseURI, List 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(List compiledVars, XQueryFunctionLibrary globalFunctionLibrary)
Check for circular definitions of global variables.
|
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 |
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 |
String | checkURIForPrefix(String prefix)
Get the URI for a prefix if there is one, return null if not.
|
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 | declareFunction(XQueryFunction function)
Register a user-defined XQuery function.
|
void | declarePrologNamespace(String prefix, String uri)
Register a namespace that is explicitly declared in the prolog of the query module.
|
void | declareVariable(VariableDeclaration var)
Declare a global variable. |
void | explainGlobalFunctions(ExpressionPresenter out)
Output "explain" information about each declared function.
|
void | fixupGlobalFunctions()
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. |
String | getBaseURI()
Get the base URI for a module |
StringCollator | getCollation(String name)
Get a named collation.
|
Configuration | getConfiguration()
Get the Saxon Configuration |
int | getConstructionMode()
Get the current construction mode
|
DecimalFormatManager | getDecimalFormatManager()
Get a DecimalFormatManager to resolve the names of decimal formats used in calls
to the format-number() function. |
String | getDefaultCollationName()
Get the name of the default collation.
|
String | getDefaultElementNamespace()
Get the default XPath namespace for elements and types. |
String | getDefaultFunctionNamespace()
Get the default function namespace
|
Executable | 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 functions |
SlotManager | getGlobalStackFrameMap()
Get the stack frame map for global variables.
|
Iterator<GlobalVariableDefinition> | getGlobalVariables()
Get all global variables declared in or imported into this module |
ImportedFunctionLibrary | getImportedFunctionLibrary()
Get the function library object that holds details of imported functions |
Set | getImportedSchemaNamespaces()
Get the set of imported schemas
|
String | getLanguageVersion()
Get the language version supported |
int | getLineNumber()
Get the line number of the expression within that container.
|
XQueryFunctionLibrary | getLocalFunctionLibrary()
Get the functions declared locally within this module |
LocationMap | getLocationMap()
Get the LocationMap, an data structure used to identify the location of compiled expressions within
the query source text.
|
URI | getLocationURI()
Get the location URI for a module |
String | getModuleNamespace()
Get the namespace of the current library module.
|
short | getModuleNamespaceCode()
Get the namesapce code of the current library module.
|
Iterator | getModuleVariables()
Get global variables declared in this module |
NamePool | getNamePool()
Get the NamePool used for compiling expressions |
NamespaceResolver | getNamespaceResolver()
Get a copy of the Namespace Context. |
int | getRevalidationMode()
Get the revalidation mode. |
String | getSystemId()
Get the System ID for a module |
QueryModule | getTopLevelModule()
Get the QueryModule for the top-level module. |
String | getURIForPrefix(String prefix)
Get the URI for a prefix.
|
UserFunction | getUserDefinedFunction(String uri, 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 user |
boolean | importsNamespace(String uri)
Ask whether this module directly imports a particular namespace
This method is intended for internal use. |
boolean | importsNamespaceIndirectly(String uri)
Test whether this module imports a particular namespace directly or indirectly
This method is intended for internal use. |
boolean | isAllowedBuiltInType(BuiltInAtomicType type)
Determine whether a built-in type is available in this context. |
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 |
boolean | isImportedSchema(String namespace)
Get the schema for a given namespace, if it has been imported
|
boolean | isInBackwardsCompatibleMode()
Determine whether Backwards Compatible Mode is used
|
boolean | isInheritNamespaces()
Get the namespace inheritance mode
|
boolean | isMainModule()
Ask whether this is a "main" module, in the sense of the XQuery language specification |
boolean | isPreserveBoundarySpace()
Ask whether the policy for boundary space is "preserve" or "strip" |
boolean | isPreserveNamespaces()
Get the namespace copy mode
|
void | issueWarning(String s, SourceLocator locator)
Issue a compile-time warning. |
boolean | isTopLevelModule()
Test whether this is a "top-level" module. |
boolean | isUpdating()
Ask whether the query is allowed to be updating |
Iterator | iterateImportedNamespaces()
Get an iterator over all the module namespaces that this module imports |
void | lookForModuleCycles(Stack referees, int lineNumber)
Look for module cycles. |
XPathContext | makeEarlyEvaluationContext()
Construct a dynamic context for early evaluation of constant subexpressions |
static QueryModule | makeQueryModule(String baseURI, Executable executable, QueryModule importer, String query, String namespaceURI, boolean allowCycles)
Supporting method to load an imported library module.
|
boolean | mayImportModule(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 | reportFatalError(XPathException err)
Report a fatal error in the query (via the registered ErrorListener) |
void | setBaseURI(String uri)
Set the base URI for a module |
void | setConstructionMode(int mode)
Set the construction mode for this module
|
void | setDefaultCollationName(String collation)
Set the name of the default collation |
void | setDefaultElementNamespace(String uri)
Set the default element namespace as declared in the query prolog |
void | setDefaultFunctionNamespace(String uri)
Set the default function namespace |
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 |
void | setExecutable(Executable executable)
Set the executable.
|
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 mode
|
void | setIsMainModule(boolean main)
Set whether this is a "Main" module, in the sense of the XQuery language specification |
void | setLocationURI(URI uri)
Set the location URI for a module |
void | setModuleNamespace(String uri)
Set the namespace for a library module.
|
void | setPreserveBoundarySpace(boolean preserve)
Set the policy for preserving boundary space |
void | setPreserveNamespaces(boolean inherit)
Set the namespace copy mode
|
void | setRevalidationMode(int mode)
Set the revalidation mode. |
void | setUpdating(boolean updating)
Set whether the query is allowed to be updating |
void | typeCheckGlobalVariables(List compiledVars)
Perform type checking on global variables.
|
void | undeclareNamespace()
Undeclare the most recently-declared active namespace. |
Parameters: sqc the StaticQueryContext object from which this module is initialized
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
This method is intended for internal use.
Parameters: uri the URI of the imported namespace.
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
Throws: net.sf.saxon.trans.XPathException if a function call refers to a function that has not been declared
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.
This method is intended for internal use
Parameters: compiledVars a list of GlobalVariableDefinition objects to be checked
Parameters: fd the declaration of the imported function
Throws: XPathException if an error is found
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.
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 "".
Parameters: prefix the namespace prefix uri the namespace URI
Parameters: function the function being declared
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.
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
Parameters: out the expression presenter used to display the output
Parameters: globalVariableMap a SlotManager that holds details of the assignment of slots to global variables.
Returns: a list containing the global variable definitions.
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.
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.
Returns: the base URI
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.
Returns: the Saxon Configuration
Returns: the decimal format manager for this static context, or null if named decimal formats are not supported in this environment.
Returns: the name of the default collation; or the name of the codepoint collation if no default collation has been defined
Returns: the default namespace, or NULL for the non-namespace
Returns: the default namespace for function names
Returns: the Executable
Returns: the FunctionLibrary used. For XQuery, this will always be a FunctionLibraryList.
See Also: FunctionLibraryList
Returns: the library of global functions
Returns: the stack frame map (a SlotManager) for global variables.
Returns: an iterator over the global variables
Returns: the library of imported functions
Returns: a Set, the set of URIs representing the names of imported schemas
Returns: the language version (currently "1.0" or "1.1")
Since: 9.2
Returns: -1 always
Returns: a FunctionLibrary object containing the function declarations
Returns: the LocationMap
Returns: the location URI
Returns: the module namespace, or null if this is a main module
Returns: the module namespace, or null if this is a main module
Returns: an Iterator whose items are GlobalVariableDefinition objects
Returns: the name pool
Returns: the revalidation mode. This will be one of STRICT, LAX, or SKIP
Returns: the location URI
Returns: the StaticQueryContext object associated with the top level module
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
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
Returns: the user-created StaticQueryContext object
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
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
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
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
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
Returns: false; XPath 1.0 compatibility mode is not supported in XQuery
Since: 8.4
Returns: true if namespaces are inherited, false if not
Since: 8.4
Returns: true if this is a main module, false if it is a library model
Returns: true if the policy is to preserve boundary space, false if it is to strip it
Returns: true if namespaces are preserved, false if not
Returns: true if this is top-level module
Returns: true if the query is allowed to use the XQuery Update facility
Since: 9.1
Returns: an iterator over the imported namespaces (delivered as strings)
[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
Returns: a dynamic context object
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
Parameters: namespace the namespace to be tested
Returns: true if the import is permitted
Parameters: err the error to be signalled
Parameters: uri the base URI
Parameters: collation the URI of the default collation
Parameters: uri the default namespace for elements and types
Parameters: uri the default namespace for functions
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
Parameters: executable the Executable
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
Parameters: inherit true if namespaces are inherited, false if not
Since: 8.4
Parameters: main true if this is a main module, false if it is a library module
Parameters: uri the location URI
Parameters: uri the module namespace URI of the library module
Parameters: preserve true if boundary space is to be preserved, false if it is to be stripped
Parameters: inherit true if namespaces are preserved, false if not
Parameters: mode the revalidation mode. This must be one of STRICT, LAX, or SKIP
Parameters: updating true if the query may use the XQuery Update facility (requires Saxon-EE)
Since: 9.1
This method is intended for internal use
Parameters: compiledVars a list of GlobalVariableDefinition objects to be checked
See Also: QueryModule