public class IndependentContext extends AbstractStaticContext implements XPathStaticContext, NamespaceResolver
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.
Modifier and Type | Field and Description |
---|---|
protected boolean |
autoDeclare |
protected Executable |
executable |
protected NamespaceResolver |
externalResolver |
protected java.util.Set<java.lang.String> |
importedSchemaNamespaces |
protected java.util.HashMap<java.lang.String,java.lang.String> |
namespaces |
protected ItemType |
requiredContextItemType |
protected RetainedStaticContext |
retainedStaticContext |
protected java.util.HashMap<StructuredQName,XPathVariable> |
variables |
usingDefaultFunctionLibrary
Constructor and Description |
---|
IndependentContext()
Create an IndependentContext along with a new (non-schema-aware) Saxon Configuration
|
IndependentContext(Configuration config)
Create an IndependentContext using a specific Configuration
|
IndependentContext(IndependentContext ic)
Create a IndependentContext as a copy of another IndependentContext
|
Modifier and Type | Method and Description |
---|---|
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, xsl, saxon).
|
void |
declareNamespace(java.lang.String prefix,
java.lang.String uri)
Declare a namespace whose prefix can be used in expressions
|
XPathVariable |
declareVariable(QNameValue qname)
Declare a variable.
|
XPathVariable |
declareVariable(java.lang.String namespaceURI,
java.lang.String localName)
Declare a variable.
|
XPathVariable |
declareVariable(StructuredQName qName)
Declare a variable.
|
int |
getColumnNumber() |
java.util.Collection<XPathVariable> |
getDeclaredVariables() |
Executable |
getExecutable() |
XPathVariable |
getExternalVariable(StructuredQName qName)
Get the declared variable with a given name, if there is one
|
java.util.Set<java.lang.String> |
getImportedSchemaNamespaces()
Get the set of imported schemas
|
int |
getLineNumber() |
NamespaceResolver |
getNamespaceResolver()
Get a namespace resolver to resolve the namespaces declared in this static context.
|
java.lang.String |
getPublicId() |
ItemType |
getRequiredContextItemType()
Get the required type of the context item.
|
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.
|
java.lang.String |
getURIForPrefix(java.lang.String prefix,
boolean useDefault)
Get the namespace URI corresponding to a given prefix.
|
boolean |
isAllowUndeclaredVariables()
Ask whether undeclared variables are allowed.
|
boolean |
isImportedSchema(java.lang.String namespace)
Ask whether a Schema for a given target namespace has been imported.
|
java.util.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. |
java.util.Iterator<java.lang.String> |
iteratePrefixes()
Get an iterator over all the prefixes declared in this namespace context.
|
RetainedStaticContext |
makeRetainedStaticContext()
Construct a RetainedStaticContext, which extracts information from this StaticContext
to provide the subset of static context information that is potentially needed
during expression evaluation.
|
void |
setAllowUndeclaredVariables(boolean allow)
Say whether undeclared variables are allowed.
|
void |
setDefaultElementNamespace(java.lang.String uri)
Set the default namespace for elements and types
|
void |
setExecutable(Executable exec) |
void |
setImportedSchemaNamespaces(java.util.Set<java.lang.String> 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.
|
void |
setRequiredContextItemType(ItemType type)
Declare the static type of the context item.
|
addFunctionLibrary, declareCollation, getConfiguration, getContainingLocation, getDecimalFormatManager, getDefaultCollationName, getDefaultElementNamespace, getDefaultFunctionNamespace, getFunctionLibrary, getHostLanguage, getKeyManager, getPackageData, getStaticBaseURI, getSystemId, getXPathVersion, isInBackwardsCompatibleMode, issueWarning, makeEarlyEvaluationContext, resolveTypeAlias, setBackwardsCompatibilityMode, setBaseURI, setConfiguration, setContainingLocation, setDecimalFormatManager, setDefaultCollationName, setDefaultFunctionLibrary, setDefaultFunctionLibrary, setDefaultFunctionNamespace, setFunctionLibrary, setPackageData, setSchemaAware, setTypeAlias, setXPathLanguageLevel
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConfiguration, getContainingLocation, getDecimalFormatManager, getDefaultCollationName, getDefaultElementNamespace, getDefaultFunctionNamespace, getFunctionLibrary, getKeyManager, getPackageData, getStaticBaseURI, getSystemId, getXPathVersion, isInBackwardsCompatibleMode, issueWarning, makeEarlyEvaluationContext, resolveTypeAlias
protected java.util.HashMap<java.lang.String,java.lang.String> namespaces
protected java.util.HashMap<StructuredQName,XPathVariable> variables
protected NamespaceResolver externalResolver
protected ItemType requiredContextItemType
protected java.util.Set<java.lang.String> importedSchemaNamespaces
protected boolean autoDeclare
protected Executable executable
protected RetainedStaticContext retainedStaticContext
public IndependentContext()
public IndependentContext(Configuration config)
config
- the Saxon configuration to be usedpublic IndependentContext(IndependentContext ic)
ic
- the IndependentContext to be copiedpublic RetainedStaticContext makeRetainedStaticContext()
makeRetainedStaticContext
in interface StaticContext
makeRetainedStaticContext
in class AbstractStaticContext
public void declareNamespace(java.lang.String prefix, java.lang.String uri)
prefix
- The namespace prefix. Must not be null. Supplying "" sets the
default element namespace.uri
- The namespace URI. Must not be null.public void setDefaultElementNamespace(java.lang.String uri)
setDefaultElementNamespace
in interface XPathStaticContext
setDefaultElementNamespace
in class AbstractStaticContext
uri
- the namespace to be used for unprefixed element and type names.
The value "" (or NamespaceConstant.NULL) represents the non-namespacepublic void clearNamespaces()
public void clearAllNamespaces()
public void setNamespaces(NodeInfo node)
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.public void setNamespaceResolver(NamespaceResolver resolver)
setNamespaceResolver
in interface XPathStaticContext
resolver
- the external NamespaceResolverpublic void setAllowUndeclaredVariables(boolean allow)
allow
- true if undeclared variables are allowed, false if they are not allowed.public boolean isAllowUndeclaredVariables()
public XPathVariable declareVariable(QNameValue qname)
declareVariable
in interface XPathStaticContext
qname
- The name of the variablepublic XPathVariable declareVariable(java.lang.String namespaceURI, java.lang.String localName)
declareVariable
in interface XPathStaticContext
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)public XPathVariable declareVariable(StructuredQName qName)
qName
- the name of the variable.public java.util.Iterator<XPathVariable> iterateExternalVariables()
allowUndeclaredVariables
is set.public XPathVariable getExternalVariable(StructuredQName qName)
qName
- the name of the required variablepublic int getSlotNumber(QNameValue qname)
qname
- the name of the variablepublic NamespaceResolver getNamespaceResolver()
StaticContext
getNamespaceResolver
in interface StaticContext
public java.lang.String getURIForPrefix(java.lang.String prefix, boolean useDefault)
getURIForPrefix
in interface NamespaceResolver
prefix
- the namespace prefixuseDefault
- true if the default namespace is to be used when the
prefix is ""public java.util.Iterator<java.lang.String> iteratePrefixes()
iteratePrefixes
in interface NamespaceResolver
public Expression bindVariable(StructuredQName qName) throws XPathException
bindVariable
in interface StaticContext
qName
- the name of the variableXPathException
- if the variable cannot be bound (has not been declared)public SlotManager getStackFrameMap()
getStackFrameMap
in interface XPathStaticContext
public java.util.Collection<XPathVariable> getDeclaredVariables()
public boolean isImportedSchema(java.lang.String namespace)
StaticContext
isImportedSchema
in interface StaticContext
namespace
- the target namespace in questionpublic java.util.Set<java.lang.String> getImportedSchemaNamespaces()
getImportedSchemaNamespaces
in interface StaticContext
public void setImportedSchemaNamespaces(java.util.Set<java.lang.String> namespaces)
namespaces
- the set of namespaces for which schema components are available in the
static contextpublic void setRequiredContextItemType(ItemType type)
type
- the required type of the context itempublic ItemType getRequiredContextItemType()
getRequiredContextItemType
in interface StaticContext
getRequiredContextItemType
in class AbstractStaticContext
public void setExecutable(Executable exec)
public Executable getExecutable()
public int getColumnNumber()
public java.lang.String getPublicId()
public int getLineNumber()
Copyright (c) 2004-2018 Saxonica Limited. All rights reserved.