Package net.sf.saxon.xpath
Class JAXPXPathStaticContext
- java.lang.Object
-
- net.sf.saxon.sxpath.AbstractStaticContext
-
- net.sf.saxon.xpath.JAXPXPathStaticContext
-
- All Implemented Interfaces:
StaticContext
,NamespaceResolver
public class JAXPXPathStaticContext extends AbstractStaticContext implements NamespaceResolver
A JAXPXPathStaticContext 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. The JAXP 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 theXPathEvaluator
-
-
Field Summary
-
Fields inherited from class net.sf.saxon.sxpath.AbstractStaticContext
usingDefaultFunctionLibrary
-
-
Constructor Summary
Constructors Constructor Description JAXPXPathStaticContext(Configuration config)
Create a JAXPXPathStaticContext using a specific Configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Expression
bindVariable(StructuredQName qName)
Bind a variable used in an XPath Expression to the XSLVariable element in which it is declared.java.util.Set<java.lang.String>
getImportedSchemaNamespaces()
Get the set of imported schemasjavax.xml.namespace.NamespaceContext
getNamespaceContext()
Get the NamespaceContext that was set usingsetNamespaceContext(javax.xml.namespace.NamespaceContext)
NamespaceResolver
getNamespaceResolver()
Get a namespace resolver to resolve the namespaces declared in this static context.SlotManager
getStackFrameMap()
Get the stack frame map containing the slot number allocations for the variables declared in this static contextjava.lang.String
getURIForPrefix(java.lang.String prefix, boolean useDefault)
Get the namespace URI corresponding to a given prefix.javax.xml.xpath.XPathFunctionResolver
getXPathFunctionResolver()
javax.xml.xpath.XPathVariableResolver
getXPathVariableResolver()
Get the XPathVariableResolvervoid
importSchema(javax.xml.transform.Source source)
Import a schema.boolean
isImportedSchema(java.lang.String namespace)
Determine whether a Schema for a given target namespace has been imported.java.util.Iterator<java.lang.String>
iteratePrefixes()
Get an iterator over all the prefixes declared in this namespace context.void
setNamespaceContext(javax.xml.namespace.NamespaceContext context)
Supply the NamespaceContext used to resolve namespaces.void
setXPathFunctionResolver(javax.xml.xpath.XPathFunctionResolver xPathFunctionResolver)
void
setXPathVariableResolver(javax.xml.xpath.XPathVariableResolver resolver)
Set an XPathVariableResolver.-
Methods inherited from class net.sf.saxon.sxpath.AbstractStaticContext
addFunctionLibrary, getConfiguration, getContainingLocation, getDecimalFormatManager, getDefaultCollationName, getDefaultElementNamespace, getDefaultFunctionNamespace, getFunctionLibrary, getKeyManager, getPackageData, getRequiredContextItemType, getStaticBaseURI, getSystemId, getUnprefixedElementMatchingPolicy, getWarningHandler, getXPathVersion, isInBackwardsCompatibleMode, issueWarning, makeEarlyEvaluationContext, makeRetainedStaticContext, resolveTypeAlias, setBackwardsCompatibilityMode, setBaseURI, setConfiguration, setContainingLocation, setDecimalFormatManager, setDefaultCollationName, setDefaultElementNamespace, setDefaultFunctionLibrary, setDefaultFunctionLibrary, setDefaultFunctionNamespace, setFunctionLibrary, setPackageData, setSchemaAware, setTypeAlias, setUnprefixedElementMatchingPolicy, setWarningHandler, setXPathLanguageLevel
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.expr.StaticContext
getOptimizerOptions
-
-
-
-
Constructor Detail
-
JAXPXPathStaticContext
public JAXPXPathStaticContext(Configuration config)
Create a JAXPXPathStaticContext using a specific Configuration.- Parameters:
config
- the Configuration. For schema-aware XPath expressions, this must be an EnterpriseConfiguration.
-
-
Method Detail
-
setNamespaceContext
public void setNamespaceContext(javax.xml.namespace.NamespaceContext context)
Supply the NamespaceContext used to resolve namespaces.- Parameters:
context
- the namespace context
-
getNamespaceContext
public javax.xml.namespace.NamespaceContext getNamespaceContext()
Get the NamespaceContext that was set usingsetNamespaceContext(javax.xml.namespace.NamespaceContext)
- Returns:
- the namespace context
-
getStackFrameMap
public SlotManager getStackFrameMap()
Get the stack frame map containing the slot number allocations for the variables declared in this static context- Returns:
- the stack frame map
-
setXPathVariableResolver
public void setXPathVariableResolver(javax.xml.xpath.XPathVariableResolver resolver)
Set an XPathVariableResolver. This is used to resolve variable references if no variable has been explicitly declared.- Parameters:
resolver
- A JAXP 1.3 XPathVariableResolver
-
getXPathVariableResolver
public javax.xml.xpath.XPathVariableResolver getXPathVariableResolver()
Get the XPathVariableResolver- Returns:
- the XPathVariableResolver
-
setXPathFunctionResolver
public void setXPathFunctionResolver(javax.xml.xpath.XPathFunctionResolver xPathFunctionResolver)
-
getXPathFunctionResolver
public javax.xml.xpath.XPathFunctionResolver getXPathFunctionResolver()
-
getNamespaceResolver
public NamespaceResolver getNamespaceResolver()
Description copied from interface:StaticContext
Get a namespace resolver to resolve the namespaces declared in this static context.- Specified by:
getNamespaceResolver
in interfaceStaticContext
- Returns:
- a namespace resolver.
-
getURIForPrefix
public java.lang.String getURIForPrefix(java.lang.String prefix, boolean useDefault)
Get the namespace URI corresponding to a given prefix. Return null if the prefix is not in scope. This method searches any namespace context supplied usingsetNamespaceContext(javax.xml.namespace.NamespaceContext)
.- Specified by:
getURIForPrefix
in interfaceNamespaceResolver
- Parameters:
prefix
- the namespace prefixuseDefault
- true if the default namespace for elements and types 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.
-
iteratePrefixes
public java.util.Iterator<java.lang.String> iteratePrefixes()
Get an iterator over all the prefixes declared in this namespace context. This method is implemented only in the case where the NamespaceContext supplied usingsetNamespaceContext(javax.xml.namespace.NamespaceContext)
is an instance of Saxon'sNamespaceResolver
class. In other cases the method throws an UnsupportedOperationException- Specified by:
iteratePrefixes
in interfaceNamespaceResolver
- Returns:
- an iterator over all the inscope namespace prefixes, if available
- Throws:
java.lang.UnsupportedOperationException
- if the NamespaceContext object is not a NamespaceResolver.
-
bindVariable
public final Expression bindVariable(StructuredQName qName) throws XPathException
Bind a variable used in an XPath Expression to the XSLVariable element in which it is declared. This method is provided for use by the XPath parser, and it should not be called by the user of the API.- Specified by:
bindVariable
in interfaceStaticContext
- Parameters:
qName
- the name of the variable to be bound- Returns:
- an expression representing the variable reference, This will often be
a
VariableReference
, suitably initialized to refer to the corresponding variable declaration, but in general it can be any expression which returns the variable's value when evaluated. - Throws:
XPathException
- if no VariableResolver has been supplied.
-
importSchema
public void importSchema(javax.xml.transform.Source source) throws SchemaException
Import a schema. This is possible only if Saxon-EE is being used, and if the Configuration is a EnterpriseConfiguration. 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:
SchemaException
- if the schema contained in this document is invalidjava.lang.UnsupportedOperationException
- if the configuration is not schema-aware
-
isImportedSchema
public boolean isImportedSchema(java.lang.String namespace)
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).- Specified by:
isImportedSchema
in interfaceStaticContext
- Parameters:
namespace
- the target namespace in question- Returns:
- true if schema components for the given namespace have been imported into the schema-aware configuration
-
getImportedSchemaNamespaces
public java.util.Set<java.lang.String> getImportedSchemaNamespaces()
Get the set of imported schemas- Specified by:
getImportedSchemaNamespaces
in interfaceStaticContext
- Returns:
- a Set, the set of URIs representing the names of imported schemas
-
-