| java.lang.Object net.sf.saxon.xpath.StandaloneContext
StandaloneContext | public class StandaloneContext implements StaticContext,NamespaceResolver(Code) | | A StandaloneContext provides a context for parsing an XPath expression
in a context other than a stylesheet. In particular, it is used to support
the JAXP 1.3 XPath API. This API does not actually expose the StaticContext
object directly; rather, the static context (namespaces, variables, and functions)
is manipulated through the XPath object, implemented in Saxon by the
XPathEvaluator |
Method Summary | |
public VariableReference | bindVariable(int fingerprint) Bind a variable used in an XPath Expression to the XSLVariable element in which it is declared. | public void | clearAllNamespaces() Clear all the declared namespaces, including the standard ones (xml, xslt, saxon). | public void | clearNamespaces() Clear all the declared namespaces, except for the standard ones (xml, xslt, saxon, xdt). | public void | declareCollation(String name, Comparator comparator, boolean isDefault) | public void | declareNamespace(String prefix, String uri) Declare a namespace whose prefix can be used in expressions. | public Variable | declareVariable(String qname, Object initialValue) Declare a variable. | public String | getBaseURI() Get the Base URI of the stylesheet element, for resolving any relative URI's used
in the expression. | public Comparator | getCollation(String name) Get a named collation. | public Configuration | getConfiguration() | public String | getDefaultCollationName() Get the name of the default collation. | public short | getDefaultElementNamespace() | public String | getDefaultFunctionNamespace() | public FunctionLibrary | getFunctionLibrary() | public Set | getImportedSchemaNamespaces() | public int | getLineNumber() Get the line number of the expression within that container. | public LocationMap | getLocationMap() | public NamePool | getNamePool() | public NamespaceContext | getNamespaceContext() | public NamespaceResolver | getNamespaceResolver() | public SlotManager | getStackFrameMap() | public String | getSystemId() Get the system ID of the container of the expression. | public String | getURIForPrefix(String prefix) Get the URI for a prefix, using the declared namespaces as
the context for namespace resolution. | public String | getURIForPrefix(String prefix, boolean useDefault) Get the namespace URI corresponding to a given prefix. | public XPathFunctionResolver | getXPathFunctionResolver() | public XPathVariableResolver | getXPathVariableResolver() | public void | importSchema(Source source) Import a schema. | public boolean | isAllowedBuiltInType(AtomicType type) Determine whether a built-in type is available in this context. | public boolean | isImportedSchema(String namespace) Determine whether a Schema for a given target namespace has been imported. | public boolean | isInBackwardsCompatibleMode() | public void | issueWarning(String s, SourceLocator locator) Issue a compile-time warning. | public Iterator | iteratePrefixes() Get an iterator over all the prefixes declared in this namespace context. | public XPathContext | makeEarlyEvaluationContext() | public void | setBackwardsCompatibilityMode(boolean backwardsCompatible) | public void | setBaseURI(String baseURI) | public void | setDefaultElementNamespace(String uri) | public void | setDefaultFunctionNamespace(String uri) | public void | setFunctionLibrary(FunctionLibrary lib) | public void | setLocationMap(LocationMap locationMap) | public void | setNamespaceContext(NamespaceContext context) Supply the NamespaceContext used to resolve namespaces. | public void | setNamespaces(NodeInfo node) Set all the declared namespaces to be the namespaces that are in-scope for a given node. | public void | setXPathFunctionResolver(XPathFunctionResolver xPathFunctionResolver) | public void | setXPathVariableResolver(XPathVariableResolver resolver) Set an XPathVariableResolver. |
StandaloneContext | public StandaloneContext()(Code) | | Create a StandaloneContext using the default Configuration and NamePool
|
StandaloneContext | public StandaloneContext(Configuration config)(Code) | | Create a StandaloneContext using a specific Configuration.
Parameters: config - the Configuration. For schema-aware XPath expressions, this must be a SchemaAwareConfiguration. |
StandaloneContext | public StandaloneContext(NodeInfo node)(Code) | | Create a StandaloneContext using a specific Node. This node is used to initialize
the NamePool and also to establish the initial set of in-scope namespaces.
|
clearAllNamespaces | public void clearAllNamespaces()(Code) | | Clear all the declared namespaces, including the standard ones (xml, xslt, saxon).
Leave only the XML namespace and the default namespace (xmlns="")
|
clearNamespaces | public void clearNamespaces()(Code) | | Clear all the declared namespaces, except for the standard ones (xml, xslt, saxon, xdt).
This doesn't clear the namespace context set using
StandaloneContext.setNamespaceContext |
declareCollation | public void declareCollation(String name, Comparator comparator, boolean isDefault)(Code) | | Declare a named collation
Parameters: name - The name of the collation (technically, a URI) Parameters: comparator - The Java Comparator used to implement the collating sequence Parameters: isDefault - True if this is to be used as the default collation |
declareNamespace | public void declareNamespace(String prefix, String uri)(Code) | | Declare a namespace whose prefix can be used in expressions. Namespaces may either be
pre-declared (the traditional Saxon interface), or they may be resolved on demand
using a supplied NamespaceContext. When a prefix has to be resolved, the parser looks
first in the pre-declared namespaces, then in the supplied NamespaceContext object.
Parameters: prefix - The namespace prefix. Must not be null. Must not be the empty string("") - unqualified names in an XPath expression always refer to the null namespace. Parameters: uri - The namespace URI. Must not be null. |
declareVariable | public Variable declareVariable(String qname, Object initialValue) throws XPathException(Code) | | Declare a variable. A variable may be declared before an expression referring
to it is compiled. Alternatively, a JAXP XPathVariableResolver may be supplied
to perform the resolution. A variable that has been explicitly declared is
used in preference.
Parameters: qname - Lexical QName identifying the variable. The namespace prefix, ifany, must have been declared before this method is called, or must be resolvableusing the namespace context. Parameters: initialValue - The initial value of the variable. A Java object that canbe converted to an XPath value. |
getBaseURI | public String getBaseURI()(Code) | | Get the Base URI of the stylesheet element, for resolving any relative URI's used
in the expression.
Used by the document() function, resolve-uri(), etc.
"" if no base URI has been set |
getCollation | public Comparator getCollation(String name)(Code) | | Get a named collation.
the collation identified by the given name, as set previously using declareCollation.Return null if no collation with this name is found. |
getDefaultCollationName | public String getDefaultCollationName()(Code) | | Get the name of the default collation.
the name of the default collation; or the name of the codepoint collationif no default collation has been defined |
getDefaultElementNamespace | public short getDefaultElementNamespace()(Code) | | Get the default XPath namespace, as a namespace code that can be looked up in the NamePool
|
getDefaultFunctionNamespace | public String getDefaultFunctionNamespace()(Code) | | Get the default function namespace
|
getFunctionLibrary | public FunctionLibrary getFunctionLibrary()(Code) | | Get the function library containing all the in-scope functions available in this static
context
|
getImportedSchemaNamespaces | public Set getImportedSchemaNamespaces()(Code) | | Get the set of imported schemas
a Set, the set of URIs representing the names of imported schemas |
getLineNumber | public int getLineNumber()(Code) | | Get the line number of the expression within that container.
Used to construct error messages.
-1 always |
getNamePool | public NamePool getNamePool()(Code) | | Get the NamePool used for compiling expressions
|
getStackFrameMap | public SlotManager getStackFrameMap()(Code) | | Get the stack frame map containing the slot number allocations for the variables declared
in this static context
|
getSystemId | public String getSystemId()(Code) | | Get the system ID of the container of the expression. Used to construct error messages.
"" always |
getURIForPrefix | public String getURIForPrefix(String prefix) throws XPathException(Code) | | Get the URI for a prefix, using the declared namespaces as
the context for namespace resolution. The default namespace is NOT used
when the prefix is empty.
This method is provided for use by the XPath parser.
Parameters: prefix - The prefix throws: net.sf.saxon.trans.XPathException - if the prefix is not declared |
importSchema | public void importSchema(Source source) throws SchemaException(Code) | | Import a schema. This is possible only if the schema-aware version of Saxon is being used,
and if the Configuration is a SchemaAwareConfiguration. Having imported a schema, the types
defined in that schema become part of the static context.
Parameters: source - A Source object identifying the schema document to be loaded throws: net.sf.saxon.type.SchemaException - if the schema contained in this document is invalid throws: UnsupportedOperationException - if the configuration is not schema-aware |
isAllowedBuiltInType | public boolean isAllowedBuiltInType(AtomicType type)(Code) | | 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.
Parameters: type - the supposedly built-in type. This will always be a type in theXS or XDT namespace. true if this type can be used in this static context |
isImportedSchema | public boolean isImportedSchema(String namespace)(Code) | | Determine whether a Schema for a given target namespace has been imported. Note that the
in-scope element declarations, attribute declarations and schema types are the types registered
with the (schema-aware) configuration, provided that their namespace URI is registered
in the static context as being an imported schema namespace. (A consequence of this is that
within a Configuration, there can only be one schema for any given namespace, including the
null namespace).
This implementation always returns false: the standalone XPath API does not supportschema-aware processing. |
isInBackwardsCompatibleMode | public boolean isInBackwardsCompatibleMode()(Code) | | Determine whether Backwards Compatible Mode is used
false; XPath 1.0 compatibility mode is not supported in the standaloneXPath API |
issueWarning | public void issueWarning(String s, SourceLocator locator)(Code) | | Issue a compile-time warning. This method is used during XPath expression compilation to
output warning conditions. The default implementation writes the message to System.err. To
change the destination of messages, create a subclass of StandaloneContext that overrides
this method.
|
makeEarlyEvaluationContext | public XPathContext makeEarlyEvaluationContext()(Code) | | Construct a dynamic context for early evaluation of constant subexpressions
|
setBackwardsCompatibilityMode | public void setBackwardsCompatibilityMode(boolean backwardsCompatible)(Code) | | Set XPath 1.0 backwards compatibility mode
Parameters: backwardsCompatible - if true, expressions will be evaluated withXPath 1.0 compatibility mode set to true. |
setBaseURI | public void setBaseURI(String baseURI)(Code) | | Set the base URI in the static context
|
setDefaultElementNamespace | public void setDefaultElementNamespace(String uri)(Code) | | Set the default namespace for element and type names
|
setDefaultFunctionNamespace | public void setDefaultFunctionNamespace(String uri)(Code) | | Set the default function namespace
|
setFunctionLibrary | public void setFunctionLibrary(FunctionLibrary lib)(Code) | | Set the function library to be used
|
setNamespaces | public void setNamespaces(NodeInfo node)(Code) | | Set all the declared namespaces to be the namespaces that are in-scope for a given node.
In addition, the standard namespaces (xml, xslt, saxon) are declared.
Parameters: node - The node whose in-scope namespaces are to be used as the context namespaces.Note that this will have no effect unless this node is an element. |
setXPathVariableResolver | public void setXPathVariableResolver(XPathVariableResolver resolver)(Code) | | Set an XPathVariableResolver. This is used to resolve variable references
if no variable has been explicitly declared.
Parameters: resolver - A JAXP 1.3 XPathVariableResolver |
|
|