net.sf.saxon.xpath
Class JAXPXPathStaticContext
- Container, NamespaceResolver, Serializable, SourceLocator, StaticContext
public class JAXPXPathStaticContext
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. 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 the
XPathEvaluator
addFunctionLibrary , declareCollation , getBaseURI , getCollation , getColumnNumber , getConfiguration , getDefaultCollationName , getDefaultElementNamespace , getDefaultFunctionNamespace , getExecutable , getFunctionLibrary , getHostLanguage , getLineNumber , getLocationMap , getLocationProvider , getNamePool , getPublicId , getSystemId , isAllowedBuiltInType , isInBackwardsCompatibleMode , issueWarning , makeEarlyEvaluationContext , replaceSubExpression , setBackwardsCompatibilityMode , setBaseURI , setConfiguration , setDefaultElementNamespace , setDefaultFunctionLibrary , setDefaultFunctionNamespace , setFunctionLibrary , setLocationMap |
JAXPXPathStaticContext
public JAXPXPathStaticContext(Configuration config)
Create a StandaloneContext using a specific Configuration.
config
- the Configuration. For schema-aware XPath expressions, this must be a SchemaAwareConfiguration.
getImportedSchemaNamespaces
public Set getImportedSchemaNamespaces()
Get the set of imported schemas
- getImportedSchemaNamespaces in interface StaticContext
- a Set, the set of URIs representing the names of imported schemas
getNamespaceContext
public NamespaceContext getNamespaceContext()
getStackFrameMap
public SlotManager getStackFrameMap()
Get the stack frame map containing the slot number allocations for the variables declared
in this static context
getURIForPrefix
public String getURIForPrefix(String prefix)
throws XPathException
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.
- getURIForPrefix in interface StaticContext
getURIForPrefix
public String getURIForPrefix(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 using setNamespaceContext(javax.xml.namespace.NamespaceContext)
.
- getURIForPrefix in interface NamespaceResolver
prefix
- the namespace prefixuseDefault
- true if the default namespace for elements and types is to be used when the
prefix is ""
- the uri for the namespace, or null if the prefix is not in scope.
Return "" if the prefix maps to the null namespace.
getXPathFunctionResolver
public XPathFunctionResolver getXPathFunctionResolver()
getXPathVariableResolver
public XPathVariableResolver getXPathVariableResolver()
Get the XPathVariableResolver
importSchema
public void importSchema(Source source)
throws SchemaException
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.
source
- A Source object identifying the schema document to be loaded
isImportedSchema
public boolean isImportedSchema(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).
- isImportedSchema in interface StaticContext
- true if schema components for the given namespace have been imported into the
schema-aware configuration
iteratePrefixes
public Iterator 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 using
setNamespaceContext(NamespaceContext)
is an
instance of Saxon's
NamespaceResolver
class. In other cases the method throws an
UnsupportedOperationException
- iteratePrefixes in interface NamespaceResolver
- an iterator over all the inscope namespace prefixes, if available
setNamespaceContext
public void setNamespaceContext(NamespaceContext context)
Supply the NamespaceContext used to resolve namespaces.
setXPathFunctionResolver
public void setXPathFunctionResolver(XPathFunctionResolver xPathFunctionResolver)
setXPathVariableResolver
public void setXPathVariableResolver(XPathVariableResolver resolver)
Set an XPathVariableResolver. This is used to resolve variable references
if no variable has been explicitly declared.
resolver
- A JAXP 1.3 XPathVariableResolver