|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.saxon.query.StaticQueryContext
StaticQueryContext is the implementation of StaticContext used when processing XQuery expressions. Note that some of the methods are intended for use internally by the query processor itself.
Note that a StaticQueryContext object may be initialized with context information that the query can use, but it is also modified when a query is compiled against it: for example, namespaces, variables, and functions declared in the query prolog are registered in the static context. Therefore, a StaticQueryContext object should not be used to compile more than one query.
Constructor Summary | |
StaticQueryContext(Configuration config)
Create a StaticQueryContext using the default NamePool |
Method Summary | |
void |
addImportedSchema(java.lang.String targetNamespace)
Add an imported schema to this static context. |
protected void |
bindUnboundFunctionCalls()
Bind function calls that could not be bound when first encountered. |
VariableDeclaration |
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.Reader source)
Prepare an XQuery query for subsequent evaluation. |
XQueryExpression |
compileQuery(java.lang.String query)
Prepare an XQuery query for subsequent evaluation. |
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 |
protected void |
fixupGlobalFunctions()
Fixup all references to global functions. |
void |
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()
|
java.util.Iterator |
getFunctionDefinitions()
Get an iterator over the Functions defined in this module |
FunctionLibrary |
getFunctionLibrary()
Get the function library containing all the in-scope functions available in this static context |
SlotManager |
getGlobalStackFrameMap()
Get the stack frame map for global variables |
int |
getLineNumber()
Get the line number of the expression within that container. |
LocationMap |
getLocationMap()
Get the location map |
java.lang.String |
getModuleNamespace()
Get the namespace of the current library module. |
short |
getModuleNamespaceCode()
Get the namesapce code of the current library 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. |
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. |
java.util.Iterator |
getVariableDeclarations()
Get an iterator over the variables defined in this module |
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 |
isPreserveNamespaces()
Get the namespace copy mode |
void |
issueWarning(java.lang.String s,
javax.xml.transform.SourceLocator locator)
Issue a compile-time warning. |
protected StaticQueryContext |
loadModule(java.lang.String namespaceURI,
java.lang.String locationURI)
Load another query module |
static StaticQueryContext |
loadQueryModule(Configuration config,
Executable executable,
java.lang.String baseURI,
java.lang.String namespaceURI,
java.lang.String locationURI,
StaticQueryContext importer)
Supporting method to load a query module. |
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)
Set the Configuration options |
void |
setConstructionMode(int mode)
Add a new validation mode to the stack of validation modes |
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)
|
void |
setInheritNamespaces(boolean inherit)
Set the namespace inheritance mode |
void |
setModuleNamespace(java.lang.String uri)
Set the namespace for a library module |
void |
setPreserveNamespaces(boolean inherit)
Set the namespace copy mode |
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 |
public StaticQueryContext(Configuration config)
Method Detail |
public void reset()
public void setConfiguration(Configuration config)
public Configuration getConfiguration()
getConfiguration
in interface StaticContext
public DocumentInfo buildDocument(javax.xml.transform.Source source) throws XPathException
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.
XPathException
public XQueryExpression compileQuery(java.lang.String query) throws XPathException
query
- The XQuery query to be evaluated, supplied as a string.
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.
java.lang.IllegalStateException
- if the StaticQueryContext has been used to compile another
query and has not been reset using reset()
public XQueryExpression compileQuery(java.io.Reader source) throws XPathException, java.io.IOException
source
- A Reader giving access to the text of the XQuery query to be compiled.
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.
java.lang.IllegalStateException
- if the StaticQueryContext has been used to compile another
query and has not been reset using reset()
public Executable getExecutable()
public void setExecutable(Executable executable)
public LocationMap getLocationMap()
StaticContext
getLocationMap
in interface StaticContext
public void declarePassiveNamespace(java.lang.String prefix, java.lang.String uri, boolean explicit) throws StaticError
prefix
- The namespace prefix. Must not be null.uri
- The namespace URI. Must not be null.explicit
-
StaticError
public void declareActiveNamespace(java.lang.String prefix, java.lang.String uri)
undeclareNamespace()
.
public void undeclareNamespace()
declareActiveNamespace(String, String)
public void clearPassiveNamespaces()
public java.lang.String getURIForPrefix(java.lang.String prefix) throws XPathException
getURIForPrefix
in interface StaticContext
prefix
- The prefix
XPathException
- if the prefix has not been declaredpublic java.lang.String checkURIForPrefix(java.lang.String prefix)
prefix
- The prefix
public int[] getActiveNamespaceCodes()
public NamespaceResolver getNamespaceResolver()
getNamespaceResolver
in interface StaticContext
public java.lang.String getDefaultFunctionNamespace()
getDefaultFunctionNamespace
in interface StaticContext
public void setDefaultFunctionNamespace(java.lang.String defaultFunctionNamespace)
defaultFunctionNamespace
- The namespace to be used for unprefixed function callspublic void setDefaultElementNamespace(java.lang.String uri) throws StaticError
StaticError
public short getDefaultElementNamespace()
getDefaultElementNamespace
in interface StaticContext
public void setModuleNamespace(java.lang.String uri)
public java.lang.String getModuleNamespace()
public short getModuleNamespaceCode()
public void setInheritNamespaces(boolean inherit)
inherit
- true if namespaces are inherited, false if notpublic boolean isInheritNamespaces()
public void setPreserveNamespaces(boolean inherit)
inherit
- true if namespaces are preserved, false if notpublic boolean isPreserveNamespaces()
public void declareCollation(java.lang.String name, java.util.Comparator comparator)
name
- The name of the collation (technically, a URI)comparator
- The Java Comparator used to implement the collating sequencepublic void declareDefaultCollation(java.lang.String name) throws XPathException
name
- The collation name
XPathException
- if the collation name has not been registeredpublic java.util.Comparator getCollation(java.lang.String name)
getCollation
in interface StaticContext
name
- The name of the required collation. Supply null to get the default collation.
public java.lang.String getDefaultCollationName()
getDefaultCollationName
in interface StaticContext
public java.util.HashMap getAllCollations()
public SlotManager getGlobalStackFrameMap()
public void declareVariable(VariableDeclaration var) throws StaticError
StaticError
public void fixupGlobalVariables(SlotManager globalVariableMap) throws StaticError
StaticError
public void explainGlobalVariables()
public java.util.Iterator getVariableDeclarations()
public SlotManager getStackFrameMap()
public NamePool getNamePool()
getNamePool
in interface StaticContext
public void issueWarning(java.lang.String s, javax.xml.transform.SourceLocator locator)
issueWarning
in interface StaticContext
public void setBaseURI(java.lang.String baseURI)
public java.lang.String getSystemId()
getSystemId
in interface StaticContext
public java.lang.String getBaseURI()
getBaseURI
in interface StaticContext
public int getLineNumber()
getLineNumber
in interface StaticContext
public VariableDeclaration bindVariable(int fingerprint) throws StaticError
bindVariable
in interface StaticContext
StaticError
public FunctionLibrary getFunctionLibrary()
getFunctionLibrary
in interface StaticContext
public void declareFunction(XQueryFunction function) throws StaticError
StaticError
protected void bindUnboundFunctionCalls() throws StaticError
StaticError
- if a function call refers to a function that has
not been declaredpublic java.util.Iterator getFunctionDefinitions()
XQueryFunction
objects. It returns
all function known to this module including those imported from elsewhere; they
can be distinguished by their namespace.protected void fixupGlobalFunctions() throws XPathException
This method is for internal use.
XPathException
public void explainGlobalFunctions() throws XPathException
XPathException
public UserFunction getUserDefinedFunction(java.lang.String uri, java.lang.String localName, int arity)
uri
- the uri of the function namelocalName
- the local part of the function namearity
- the number of arguments.public boolean isInBackwardsCompatibleMode()
isInBackwardsCompatibleMode
in interface StaticContext
public void addImportedSchema(java.lang.String targetNamespace)
targetNamespace
- The target namespace of the schema to be addedpublic boolean isImportedSchema(java.lang.String namespace)
isImportedSchema
in interface StaticContext
namespace
- The namespace of the required schema. Supply "" for
a no-namespace schema.
public void setConstructionMode(int mode)
public int getConstructionMode()
protected StaticQueryContext loadModule(java.lang.String namespaceURI, java.lang.String locationURI) throws StaticError
StaticError
public static StaticQueryContext loadQueryModule(Configuration config, Executable executable, java.lang.String baseURI, java.lang.String namespaceURI, java.lang.String locationURI, StaticQueryContext importer) throws StaticError
config
- The configurationexecutable
- The ExecutationbaseURI
- The base URI of the invoking modulenamespaceURI
- namespace of the query module to be loadedlocationURI
- location hint of the query module to be loadedimporter
- The importing query module (used to check for cycles)
StaticError
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |