Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sf.saxon.query
Class StaticQueryContext

    java.lang.Object
      net.sf.saxon.query.StaticQueryContext

All Implemented Interfaces:
  StaticContext

public class StaticQueryContext
extends java.lang.Object
implements StaticContext

StaticQueryContext is the implementation of StaticContext used when processing XQuery expressions.

The StaticQueryContext object has two different usages. The application constructs a StaticQueryContext and initializes it with information about the context, for example, default namespaces, base URI, and so on. When a query is compiled using this StaticQueryContext, the query parser makes a copy of the StaticQueryContext and uses this internally, modifying it with information obtained from the query prolog, as well as information such as namespace and variable declarations that can occur at any point in the query. The query parser does not modify the original StaticQueryContext supplied by the calling application, which may therefore be used for compiling multiple queries, serially or even in multiple threads.

This class forms part of Saxon's published XQuery API. Note that some of the methods are intended for use internally by the query processor itself: these are labelled as such. Methods that are considered stable are labelled with the JavaDoc "since" tag. The value 8.4 indicates a method introduced at or before Saxon 8.4; other values indicate the version at which the method was introduced.

In the longer term, this entire API may at some stage be superseded by a proposed standard Java API for XQuery.

Since:
  8.4

Constructor Summary
`StaticQueryContext(Configuration config)` Create a StaticQueryContext using a given Configuration.
`StaticQueryContext(Configuration config, StaticQueryContext importer)` Create a StaticQueryContext for a library module.

Method Summary
`void` | `addImportedNamespace(java.lang.String uri)` Register that this module imports a particular module namespace
`void` | `addImportedSchema(java.lang.String targetNamespace)` 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
`VariableReference` | `bindVariable(int fingerprint)` Bind a variable used in a query to the expression in which it is declared.
`DocumentInfo` | `buildDocument(javax.xml.transform.Source source)` Convenience method for building Saxon's internal representation of a source XML document.
`java.lang.String` | `checkURIForPrefix(java.lang.String prefix)` Get the URI for a prefix if there is one, return null if not.
`void` | `clearPassiveNamespaces()` Clear all the declared passive namespaces, except for the standard ones (xml, saxon, etc)
`XQueryExpression` | `compileQuery(java.io.InputStream source, java.lang.String encoding)` Prepare an XQuery query for subsequent evaluation.
`XQueryExpression` | `compileQuery(java.io.Reader source)` Prepare an XQuery query for subsequent evaluation.
`XQueryExpression` | `compileQuery(java.lang.String query)` Prepare an XQuery query for subsequent evaluation.
`StaticQueryContext` | `copy()` Make a copy of this StaticQueryContext.
`void` | `declareActiveNamespace(java.lang.String prefix, java.lang.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(java.lang.String name, java.util.Comparator comparator)` Declare a named collation.
`void` | `declareDefaultCollation(java.lang.String name)` Set the default collation.
`void` | `declareFunction(XQueryFunction function)` Register a user-defined XQuery function.
`void` | `declarePassiveNamespace(java.lang.String prefix, java.lang.String uri, boolean explicit)` Declare a namespace whose prefix can be used in expressions.
`void` | `declareVariable(VariableDeclaration var)` Declare a global variable.
`void` | `explainGlobalFunctions()` Output "explain" information about each declared function.
`void` | `explainGlobalVariables()` Produce "explain" output for all global variables.
`void` | `fixupGlobalFunctions()` Fixup all references to global functions.
`java.util.List` | `fixupGlobalVariables(SlotManager globalVariableMap)` Fixup all references to global variables.
`int[]` | `getActiveNamespaceCodes()` Get an array containing the namespace codes of all active namespaces.
`java.util.HashMap` | `getAllCollations()` Get a HashMap that maps all registered collations to Comparators.
`java.lang.String` | `getBaseURI()` Get the Base URI of the query, for resolving any relative URI's used in the expression.
`java.util.Comparator` | `getCollation(java.lang.String name)` Get a named collation.
`Configuration` | `getConfiguration()` Get the Configuration options
`int` | `getConstructionMode()` Get the current validation mode
`java.lang.String` | `getDefaultCollationName()` Get the name of the default collation.
`short` | `getDefaultElementNamespace()` Get the default XPath namespace, as a namespace URI code that can be looked up in the NamePool
`java.lang.String` | `getDefaultFunctionNamespace()` Get the default function namespace
`Executable` | `getExecutable()` Get the Executable, an object representing the compiled query and its environment.
`NamespaceResolver` | `getExternalNamespaceResolver()` Get the external namespace resolver that has been registered using setExternalNamespaceResolver(), if any.
`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()`
`SlotManager` | `getGlobalStackFrameMap()` Get the stack frame map for global variables.
`ImportedFunctionLibrary` | `getImportedFunctionLibrary()`
`java.util.Set` | `getImportedSchemaNamespaces()` Get the set of imported schemas
`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.
`java.lang.String` | `getLocationURI()` Get the location URI for a module
`java.lang.String` | `getModuleNamespace()` Get the namespace of the current library module.
`short` | `getModuleNamespaceCode()` Get the namesapce code of the current library module.
`java.util.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.
`SlotManager` | `getStackFrameMap()` Get the stack frame map for local variables in the "main" query expression.
`java.lang.String` | `getSystemId()` Get the system ID of the container of the expression.
`StaticQueryContext` | `getTopLevelModule(StaticQueryContext start)` Get the Static Query Context for the top-level module.
`java.util.List` | `getUndeclaredVariables(SlotManager globalVariableMap)` Get references to undeclared variables.
`java.lang.String` | `getURIForPrefix(java.lang.String prefix)` Get the URI for a prefix.
`UserFunction` | `getUserDefinedFunction(java.lang.String uri, java.lang.String localName, int arity)` Get the function with a given name and arity.
`boolean` | `importsNamespace(java.lang.String uri)` Test whether this module directly imports a particular namespace
`boolean` | `importsNamespaceIndirectly(java.lang.String uri)` Test whether this module imports a particular namespace directly or indirectly
`boolean` | `isAllowedBuiltInType(AtomicType type)` Determine whether a built-in type is available in this context.
`boolean` | `isImportedSchema(java.lang.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()` Test whether this is a "main" module, in the sense of the XQuery language specification
`boolean` | `isPreserveNamespaces()` Get the namespace copy mode
`void` | `issueWarning(java.lang.String s, javax.xml.transform.SourceLocator locator)` Issue a compile-time warning.
`boolean` | `isTopLevelModule()` Test whether this is a "top-level" module.
`java.util.Iterator` | `iterateImportedNamespaces()` Get an iterator over all the module namespaces that this module imports
`XPathContext` | `makeEarlyEvaluationContext()` Construct a dynamic context for early evaluation of constant subexpressions
`static StaticQueryContext` | `makeStaticQueryContext(java.lang.String baseURI, Executable executable, StaticQueryContext importer, java.lang.String query, java.lang.String namespaceURI)` Supporting method to load a query module.
`boolean` | `mayImport(java.lang.String namespace)` Check whether this module is allowed to import a module with namespace N.
`void` | `reset()` Reset the state of this StaticQueryContext to an uninitialized state
`void` | `setBaseURI(java.lang.String baseURI)` Set the Base URI of the query
`void` | `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 module
`void` | `setDefaultElementNamespace(java.lang.String uri)` Set the default element namespace
`void` | `setDefaultFunctionNamespace(java.lang.String defaultFunctionNamespace)` Set the default function namespace
`void` | `setExecutable(Executable executable)` Set the executable.
`void` | `setExternalNamespaceResolver(NamespaceResolver resolver)` 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 mode
`void` | `setLocationURI(java.lang.String uri)` Set the location URI for a module
`void` | `setModuleNamespace(java.lang.String uri)` Set the namespace for a library module.
`void` | `setPreserveNamespaces(boolean inherit)` Set the namespace copy mode
`void` | `typeCheckGlobalVariables(java.util.List compiledVars)`
`void` | `undeclareNamespace()` Undeclare the most recently-declared active namespace.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### StaticQueryContext

    public StaticQueryContext(Configuration config)

  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

    public StaticQueryContext(Configuration config,
                              StaticQueryContext importer)

  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 Detail

### 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

    public boolean mayImport(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 (the only case where cycles are allowed)

### getGlobalFunctionLibrary

    public XQueryFunctionLibrary getGlobalFunctionLibrary()

### getImportedFunctionLibrary

    public ImportedFunctionLibrary getImportedFunctionLibrary()

### addImportedNamespace

    public void addImportedNamespace(java.lang.String uri)

  Register that this module imports a particular module namespace

### importsNamespace

    public boolean importsNamespace(java.lang.String uri)

  Test whether this module directly imports a particular namespace

### importsNamespaceIndirectly

    public boolean importsNamespaceIndirectly(java.lang.String uri)

  Test whether this module imports a particular namespace directly or indirectly

### iterateImportedNamespaces

    public java.util.Iterator iterateImportedNamespaces()

  Get an iterator over all the module namespaces that this module imports

### getTopLevelModule

    public StaticQueryContext getTopLevelModule(StaticQueryContext start)

  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

    public StaticQueryContext 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

    public void setConfiguration(Configuration config)

  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:
    `java.lang.IllegalArgumentException` - if the configuration supplied is different from the existing configuration
  Since:
    8.4

### getConfiguration

    public Configuration getConfiguration()

  Get the Configuration options

  Specified by:
    `getConfiguration` in interface `StaticContext`
  Since:
    8.4

### makeEarlyEvaluationContext

    public XPathContext makeEarlyEvaluationContext()

  Construct a dynamic context for early evaluation of constant subexpressions

  Specified by:
    `makeEarlyEvaluationContext` in interface `StaticContext`

### buildDocument

    public DocumentInfo buildDocument(javax.xml.transform.Source source)
                               throws XPathException

  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 Saxon `DocumentInfo` (indeed any `NodeInfo`) can be used as a Source. To use a third-party DOM Document as a source, create an instance of `DOMSource` 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

    public XQueryExpression compileQuery(java.lang.String query)
                                  throws XPathException

  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

    public XQueryExpression compileQuery(java.io.Reader source)
                                  throws XPathException,
                                         java.io.IOException

  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.
    `java.io.IOException` - if a failure occurs reading the supplied input.
  Since:
    8.4

### compileQuery

    public XQueryExpression compileQuery(java.io.InputStream source,
                                         java.lang.String encoding)
                                  throws XPathException,
                                         java.io.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 octets
    `encoding` - 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.
    `java.io.IOException` - if a failure occurs reading the supplied input.
  Since:
    8.5

### 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

### getLocationMap

    public LocationMap getLocationMap()

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

  This method is intended for internal use only.

  Specified by:
    `getLocationMap` in interface `StaticContext`
  Returns:
    the LocationMap

### declarePassiveNamespace

    public void declarePassiveNamespace(java.lang.String prefix,
                                        java.lang.String uri,
                                        boolean explicit)
                                 throws StaticError

  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

    public void declareActiveNamespace(java.lang.String prefix,
                                       java.lang.String uri)

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

  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:
    `declareActiveNamespace(String, String)`

### clearPassiveNamespaces

    public void clearPassiveNamespaces()

  Clear all the declared passive namespaces, except for the standard ones (xml, saxon, etc)

  Since:
    8.4

### setExternalNamespaceResolver

    public void setExternalNamespaceResolver(NamespaceResolver resolver)

  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

    public NamespaceResolver getExternalNamespaceResolver()

  Get the external namespace resolver that has been registered using setExternalNamespaceResolver(), if any.

### getURIForPrefix

    public java.lang.String getURIForPrefix(java.lang.String prefix)
                                     throws XPathException

  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 interface `StaticContext`
  Parameters:
    `prefix` - The prefix
  Returns:
    the corresponding namespace URI
  Throws:
    `XPathException` - if the prefix has not been declared

### checkURIForPrefix

    public java.lang.String 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.
  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

    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.

  This method is for internal use only.

  Specified by:
    `getNamespaceResolver` in interface `StaticContext`
  Returns:
    a namespace resolver.

### getDefaultFunctionNamespace

    public java.lang.String getDefaultFunctionNamespace()

  Get the default function namespace

  Specified by:
    `getDefaultFunctionNamespace` in interface `StaticContext`
  Returns:
    the default function namespace (defaults to the fn: namespace)
  Since:
    8.4

### setDefaultFunctionNamespace

    public void setDefaultFunctionNamespace(java.lang.String defaultFunctionNamespace)

  Set the default function namespace

  Parameters:
    `defaultFunctionNamespace` - The namespace to be used for unprefixed function calls
  Since:
    8.4

### setDefaultElementNamespace

    public void setDefaultElementNamespace(java.lang.String uri)
                                    throws StaticError

  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 interface `StaticContext`
  Since:
    8.4

### setModuleNamespace

    public void setModuleNamespace(java.lang.String uri)

  Set the namespace for a library module.

  This method is for internal use only.

### getModuleNamespace

    public java.lang.String getModuleNamespace()

  Get the namespace of the current library module.

  This method is intended primarily for internal use.

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

### getModuleNamespaceCode

    public short getModuleNamespaceCode()

  Get the namesapce code of the current library module.

  This method is intended primarily for internal use.

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

### setLocationURI

    public void setLocationURI(java.lang.String uri)

  Set the location URI for a module

### getLocationURI

    public java.lang.String getLocationURI()

  Get the location URI for a module

### 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

    public void declareCollation(java.lang.String name,
                                 java.util.Comparator comparator)

  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

    public void declareDefaultCollation(java.lang.String name)

  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

    public java.util.Comparator getCollation(java.lang.String name)

  Get a named collation.

  Specified by:
    `getCollation` in interface `StaticContext`
  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

    public java.lang.String getDefaultCollationName()

  Get the name of the default collation.

  Specified by:
    `getDefaultCollationName` in interface `StaticContext`
  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

    public java.util.HashMap 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.

### getGlobalStackFrameMap

    public SlotManager getGlobalStackFrameMap()

  Get the stack frame map for global variables.

  This method is intended for internal use.

### declareVariable

    public void declareVariable(VariableDeclaration var)
                         throws StaticError

  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.

  Throws:
    `StaticError`
  Since:
    8.4

### fixupGlobalVariables

    public java.util.List fixupGlobalVariables(SlotManager globalVariableMap)
                                        throws StaticError

  Fixup all references to global variables.

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

  Throws:
    `StaticError`

### getModuleVariables

    public java.util.Iterator getModuleVariables()

  Get global variables declared in this module

  Returns:
    an Iterator whose items are GlobalVariableDefinition objects

### getUndeclaredVariables

    public java.util.List getUndeclaredVariables(SlotManager globalVariableMap)
                                          throws StaticError

  Get references to undeclared variables.

  Returns:
    a list of XPathException objects, one for each undeclared variable
  Throws:
    `StaticError`

### typeCheckGlobalVariables

    public void typeCheckGlobalVariables(java.util.List compiledVars)
                                  throws StaticError

  Throws:
    `StaticError`

### explainGlobalVariables

    public void explainGlobalVariables()

  Produce "explain" output for all global variables.

  This method is intended primarily for internal use.

### getStackFrameMap

    public SlotManager getStackFrameMap()

  Get the stack frame map for local variables in the "main" query expression.

  This method is intended for internal use only.

### getNamePool

    public NamePool getNamePool()

  Get the NamePool used for compiling expressions

  Specified by:
    `getNamePool` in interface `StaticContext`
  Since:
    8.4

### issueWarning

    public void issueWarning(java.lang.String s,
                             javax.xml.transform.SourceLocator locator)

  Issue a compile-time warning. This method is used during XQuery expression compilation to output warning conditions.

  This method is intended for internal use only.

  Specified by:
    `issueWarning` in interface `StaticContext`

### setBaseURI

    public void setBaseURI(java.lang.String baseURI)

  Set the Base URI of the query

  Since:
    8.4

### getSystemId

    public java.lang.String 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 interface `StaticContext`
  Returns:
    the Base URI
  Since:
    8.4

### getBaseURI

    public java.lang.String 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 interface `StaticContext`
  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 interface `StaticContext`
  Returns:
    -1 always

### bindVariable

    public VariableReference bindVariable(int fingerprint)
                                   throws StaticError

  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 interface `StaticContext`
  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

    public void setFunctionLibraryList(FunctionLibraryList functionLibrary)

  Set the function library used for binding any function call appearing within the query module.

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

  Parameters:
    `functionLibrary` - the FunctionLibrary to be used. This will typically be a FunctionLibraryList; in most cases it will be a slightly modified copy of a FunctionLibraryList constructed by the system and obtained using the `getFunctionLibrary()` method.
  See Also:
    `FunctionLibraryList`

### 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 interface `StaticContext`
  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

### declareFunction

    public void declareFunction(XQueryFunction function)
                         throws StaticError

  Register a user-defined XQuery function.

  This method is intended for internal use only.

  Throws:
    `StaticError`

### 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:
    `StaticError` - if a function call refers to a function that has not been declared
    `XPathException`

### 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.

  Throws:
    `XPathException`

### explainGlobalFunctions

    public void explainGlobalFunctions()
                                throws XPathException

  Output "explain" information about each declared function.

  This method is intended primarily for internal use.

  Throws:
    `XPathException`

### getUserDefinedFunction

    public UserFunction getUserDefinedFunction(java.lang.String 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 name
    `localName` - the local part of the function name
    `arity` - the number of arguments.
  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`

### isInBackwardsCompatibleMode

    public boolean isInBackwardsCompatibleMode()

  Determine whether Backwards Compatible Mode is used

  Specified by:
    `isInBackwardsCompatibleMode` in interface `StaticContext`
  Returns:
    false; XPath 1.0 compatibility mode is not supported in XQuery
  Since:
    8.4

### addImportedSchema

    public void addImportedSchema(java.lang.String targetNamespace)

  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

    public boolean isImportedSchema(java.lang.String namespace)

  Get the schema for a given namespace, if it has been imported

  Specified by:
    `isImportedSchema` in interface `StaticContext`
  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 getImportedSchemaNamespaces()

  Get the set of imported schemas

  Specified by:
    `getImportedSchemaNamespaces` in interface `StaticContext`
  Returns:
    a Set, the set of URIs representing the names of imported schemas

### isAllowedBuiltInType

    public boolean isAllowedBuiltInType(AtomicType type)

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

  Specified by:
    `isAllowedBuiltInType` in interface `StaticContext`
  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 of `Validation.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(java.lang.String baseURI,
                                                            Executable executable,
                                                            StaticQueryContext importer,
                                                            java.lang.String query,
                                                            java.lang.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 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
  Returns:
    The StaticQueryContext representing the loaded query module
  Throws:
    `StaticError`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD