net.sf.saxon.sxpath
public class IndependentContext extends AbstractStaticContext implements XPathStaticContext, NamespaceResolver, Serializable, Container
This class is used in a number of places where freestanding XPath expressions occur. These include the native Saxon XPath API, the .NET XPath API, XPath expressions used in XML Schema identity constraints, and XPath expressions supplied to saxon:evaluate(). It is not used by the JAXP XPath API (though it shares code with that API through the common superclass AbstractStaticContext).
This class currently provides no mechanism for binding user-defined functions.
Constructor Summary | |
---|---|
IndependentContext()
Create an IndependentContext along with a new (non-schema-aware) Saxon Configuration | |
IndependentContext(Configuration config)
Create an IndependentContext using a specific Configuration |
Method Summary | |
---|---|
Expression | bindVariable(StructuredQName qName)
Bind a variable used in an XPath Expression to the XSLVariable element in which it is declared.
|
void | clearAllNamespaces()
Clear all the declared namespaces, including the standard ones (xml, xslt, saxon).
|
void | clearNamespaces()
Clear all the declared namespaces, except for the standard ones (xml, xslt, saxon, xdt).
|
IndependentContext | copy()
Create a copy of this IndependentContext. |
void | declareNamespace(String prefix, String uri)
Declare a namespace whose prefix can be used in expressions |
XPathVariable | declareVariable(QNameValue qname)
Declare a variable. |
XPathVariable | declareVariable(String namespaceURI, String localName)
Declare a variable. |
XPathVariable | declareVariable(StructuredQName qName)
Declare a variable. |
int | getContainerGranularity()
Get the granularity of the container. |
XPathVariable | getExternalVariable(StructuredQName qName)
Get the declared variable with a given name, if there is one |
Set | getImportedSchemaNamespaces()
Get the set of imported schemas |
NamespaceResolver | getNamespaceResolver() |
int | getSlotNumber(QNameValue qname)
Get the slot number allocated to a particular variable |
SlotManager | getStackFrameMap()
Get a Stack Frame Map containing definitions of all the declared variables. |
String | getURIForPrefix(String prefix)
Get the URI for a prefix, using the declared namespaces as
the context for namespace resolution. |
String | getURIForPrefix(String prefix, boolean useDefault)
Get the namespace URI corresponding to a given prefix. |
boolean | isAllowUndeclaredVariables()
Ask whether undeclared variables are allowed. |
boolean | isImportedSchema(String namespace) |
Iterator<XPathVariable> | iterateExternalVariables()
Get an iterator over all the variables that have been declared, either explicitly by an
application call on declareVariable(), or implicitly if the option allowUndeclaredVariables
is set. |
Iterator | iteratePrefixes()
Get an iterator over all the prefixes declared in this namespace context. |
void | setAllowUndeclaredVariables(boolean allow)
Say whether undeclared variables are allowed. |
void | setImportedSchemaNamespaces(Set namespaces)
Register the set of imported schema namespaces |
void | setNamespaceResolver(NamespaceResolver resolver)
Set an external namespace resolver. |
void | setNamespaces(NodeInfo node)
Declares all the namespaces that are in-scope for a given node, removing all previous
namespace declarations.
|
Parameters: config the Saxon configuration to be used
Parameters: qName the name of the variable
Returns: the resulting variable reference
Returns: the new copy
Parameters: prefix The namespace prefix. Must not be null. Supplying "" sets the default element namespace. uri The namespace URI. Must not be null.
Parameters: qname The name of the variable
Returns: an XPathVariable object representing information about the variable that has been declared.
Parameters: namespaceURI The namespace URI of the name of the variable. Supply "" to represent names in no namespace (null is also accepted) localName The local part of the name of the variable (an NCName)
Returns: an XPathVariable object representing information about the variable that has been declared.
Parameters: qName the name of the variable.
Returns: an XPathVariable object representing information about the variable that has been declared.
Since: 9.2
Returns: 0 for a temporary container created during parsing; 1 for a container that operates at the level of an XPath expression; 2 for a container at the level of a global function or template
Parameters: qName the name of the required variable
Returns: the explicitly or implicitly declared variable with this name if it exists, or null otherwise
Since: 9.2
Returns: a Set, the set of URIs representing the names of imported schemas
Parameters: qname the name of the variable
Returns: the slot number, or -1 if the variable has not been declared
Parameters: prefix The prefix
Throws: net.sf.saxon.trans.XPathException if the prefix is not declared
Parameters: prefix the namespace prefix useDefault true if the default namespace is to be used when the prefix is ""
Returns: the uri for the namespace, or null if the prefix is not in scope. Return "" if the prefix maps to the null namespace.
Returns: true if undeclared variables are allowed, false if they are not allowed.
Since: 9.2
allowUndeclaredVariables
is set.Returns: an iterator; the objects returned by this iterator will be instances of XPathVariable
Since: 9.2
Parameters: allow true if undeclared variables are allowed, false if they are not allowed.
Since: 9.2
Parameters: namespaces the set of namespaces for which schema components are available in the static context
Parameters: resolver the external NamespaceResolver
Parameters: node The node whose in-scope namespaces are to be used as the context namespaces. If the node is an attribute, text node, etc, then the namespaces of its parent element are used.