|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.saxon.xpath.StandaloneContext
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
Constructor Summary | |
StandaloneContext()
Create a StandaloneContext using the default Configuration and NamePool |
|
StandaloneContext(Configuration config)
Create a StandaloneContext using a specific Configuration. |
|
StandaloneContext(NodeInfo node)
Create a StandaloneContext using a specific Node. |
Method Summary | |
VariableReference |
bindVariable(int fingerprint)
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). |
void |
declareCollation(java.lang.String name,
java.util.Comparator comparator,
boolean isDefault)
Declare a named collation |
void |
declareNamespace(java.lang.String prefix,
java.lang.String uri)
Declare a namespace whose prefix can be used in expressions. |
Variable |
declareVariable(java.lang.String qname,
java.lang.Object initialValue)
Declare a variable. |
java.lang.String |
getBaseURI()
Get the Base URI of the stylesheet element, for resolving any relative URI's used in the expression. |
java.util.Comparator |
getCollation(java.lang.String name)
Get a named collation. |
Configuration |
getConfiguration()
Get the system configuration |
java.lang.String |
getDefaultCollationName()
Get the name of the default collation. |
short |
getDefaultElementNamespace()
Get the default XPath namespace, as a namespace code that can be looked up in the NamePool |
java.lang.String |
getDefaultFunctionNamespace()
Get the default function namespace |
FunctionLibrary |
getFunctionLibrary()
Get the function library containing all the in-scope functions available in this static context |
java.util.Set |
getImportedSchemaNamespaces()
Get the set of imported schemas |
int |
getLineNumber()
Get the line number of the expression within that container. |
LocationMap |
getLocationMap()
Get the location map. |
NamePool |
getNamePool()
Get the NamePool used for compiling expressions |
javax.xml.namespace.NamespaceContext |
getNamespaceContext()
Get the NamespaceContext that was set using setNamespaceContext(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 context |
java.lang.String |
getSystemId()
Get the system ID of the container of the expression. |
java.lang.String |
getURIForPrefix(java.lang.String prefix)
Get the URI for a prefix, using the declared namespaces as the context for namespace resolution. |
java.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 XPathVariableResolver |
void |
importSchema(javax.xml.transform.Source source)
Import a schema. |
boolean |
isAllowedBuiltInType(AtomicType type)
Determine whether a built-in type is available in this context. |
boolean |
isImportedSchema(java.lang.String namespace)
Determine whether a Schema for a given target namespace has been imported. |
boolean |
isInBackwardsCompatibleMode()
Determine whether Backwards Compatible Mode is used |
void |
issueWarning(java.lang.String s,
javax.xml.transform.SourceLocator locator)
Issue a compile-time warning. |
java.util.Iterator |
iteratePrefixes()
Get an iterator over all the prefixes declared in this namespace context. |
XPathContext |
makeEarlyEvaluationContext()
Construct a dynamic context for early evaluation of constant subexpressions |
void |
setBackwardsCompatibilityMode(boolean backwardsCompatible)
Set XPath 1.0 backwards compatibility mode |
void |
setBaseURI(java.lang.String baseURI)
Set the base URI in the static context |
void |
setDefaultElementNamespace(java.lang.String uri)
Set the default namespace for element and type names |
void |
setDefaultFunctionNamespace(java.lang.String uri)
Set the default function namespace |
void |
setFunctionLibrary(FunctionLibrary lib)
Set the function library to be used |
void |
setLocationMap(LocationMap locationMap)
|
void |
setNamespaceContext(javax.xml.namespace.NamespaceContext context)
Supply the NamespaceContext used to resolve namespaces. |
void |
setNamespaces(NodeInfo node)
Set all the declared namespaces to be the namespaces that are in-scope for a given node. |
void |
setXPathFunctionResolver(javax.xml.xpath.XPathFunctionResolver xPathFunctionResolver)
|
void |
setXPathVariableResolver(javax.xml.xpath.XPathVariableResolver resolver)
Set an XPathVariableResolver. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public StandaloneContext()
public StandaloneContext(Configuration config)
config
- the Configuration. For schema-aware XPath expressions, this must be a SchemaAwareConfiguration.public StandaloneContext(NodeInfo node)
Method Detail |
public Configuration getConfiguration()
getConfiguration
in interface StaticContext
public XPathContext makeEarlyEvaluationContext()
makeEarlyEvaluationContext
in interface StaticContext
public LocationMap getLocationMap()
StaticContext
getLocationMap
in interface StaticContext
public void setLocationMap(LocationMap locationMap)
public void declareNamespace(java.lang.String prefix, java.lang.String uri)
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.uri
- The namespace URI. Must not be null.public void setNamespaceContext(javax.xml.namespace.NamespaceContext context)
declareNamespace(java.lang.String, java.lang.String)
or
that have been implicitly declared using setNamespaces(net.sf.saxon.om.NodeInfo)
public javax.xml.namespace.NamespaceContext getNamespaceContext()
setNamespaceContext(javax.xml.namespace.NamespaceContext)
public void clearNamespaces()
setNamespaceContext(javax.xml.namespace.NamespaceContext)
public void clearAllNamespaces()
public void setNamespaces(NodeInfo node)
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.public void setBaseURI(java.lang.String baseURI)
public void declareCollation(java.lang.String name, java.util.Comparator comparator, boolean isDefault)
name
- The name of the collation (technically, a URI)comparator
- The Java Comparator used to implement the collating sequenceisDefault
- True if this is to be used as the default collationpublic SlotManager getStackFrameMap()
public Variable declareVariable(java.lang.String qname, java.lang.Object initialValue) throws XPathException
qname
- Lexical QName identifying the variable. The namespace prefix, if
any, must have been declared before this method is called, or must be resolvable
using the namespace context.initialValue
- The initial value of the variable. A Java object that can
be converted to an XPath value.
XPathException
public void setXPathVariableResolver(javax.xml.xpath.XPathVariableResolver resolver)
resolver
- A JAXP 1.3 XPathVariableResolverpublic javax.xml.xpath.XPathVariableResolver getXPathVariableResolver()
public void setXPathFunctionResolver(javax.xml.xpath.XPathFunctionResolver xPathFunctionResolver)
public javax.xml.xpath.XPathFunctionResolver getXPathFunctionResolver()
public NamePool getNamePool()
getNamePool
in interface StaticContext
public void issueWarning(java.lang.String s, javax.xml.transform.SourceLocator locator)
issueWarning
in interface StaticContext
public java.lang.String getSystemId()
getSystemId
in interface StaticContext
public java.lang.String getBaseURI()
getBaseURI
in interface StaticContext
public int getLineNumber()
getLineNumber
in interface StaticContext
public java.lang.String getURIForPrefix(java.lang.String prefix) throws XPathException
getURIForPrefix
in interface StaticContext
prefix
- The prefix
XPathException
- if the prefix is not declaredpublic NamespaceResolver getNamespaceResolver()
StaticContext
getNamespaceResolver
in interface StaticContext
public java.lang.String getURIForPrefix(java.lang.String prefix, boolean useDefault)
declareNamespace(String, String)
, and then searches
any namespace context supplied using setNamespaceContext(javax.xml.namespace.NamespaceContext)
.
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 iteratePrefixes()
declareNamespace(String, String)
; it does not
include namespaces declared using setNamespaceContext(javax.xml.namespace.NamespaceContext)
,
because the JAXP NamespaceContext
class provides no way to discover all the namespaces
available.
iteratePrefixes
in interface NamespaceResolver
public VariableReference bindVariable(int fingerprint) throws StaticError
If the variable has been explicitly declared using declareVariable(String, Object)
,
that value is used; otherwise if a variable resolved has been supplied using
setXPathVariableResolver(javax.xml.xpath.XPathVariableResolver)
then that is used.
bindVariable
in interface StaticContext
fingerprint
- the name of the variable
StaticError
- If no variable with the given name is found, or if the value supplied
for the variable cannot be converted to an XPath value.public FunctionLibrary getFunctionLibrary()
getFunctionLibrary
in interface StaticContext
public void setFunctionLibrary(FunctionLibrary lib)
public java.util.Comparator getCollation(java.lang.String name)
getCollation
in interface StaticContext
name
- The name of the required collation. Supply null to get the default collation.
public java.lang.String getDefaultCollationName()
getDefaultCollationName
in interface StaticContext
public void setDefaultElementNamespace(java.lang.String uri)
public short getDefaultElementNamespace()
getDefaultElementNamespace
in interface StaticContext
public void setDefaultFunctionNamespace(java.lang.String uri)
public java.lang.String getDefaultFunctionNamespace()
getDefaultFunctionNamespace
in interface StaticContext
public void setBackwardsCompatibilityMode(boolean backwardsCompatible)
backwardsCompatible
- if true, expressions will be evaluated with
XPath 1.0 compatibility mode set to true.public boolean isInBackwardsCompatibleMode()
isInBackwardsCompatibleMode
in interface StaticContext
public void importSchema(javax.xml.transform.Source source) throws SchemaException
source
- A Source object identifying the schema document to be loaded
SchemaException
- if the schema contained in this document is invalid
java.lang.UnsupportedOperationException
- if the configuration is not schema-awarepublic boolean isImportedSchema(java.lang.String namespace)
isImportedSchema
in interface StaticContext
public java.util.Set getImportedSchemaNamespaces()
getImportedSchemaNamespaces
in interface StaticContext
public boolean isAllowedBuiltInType(AtomicType type)
isAllowedBuiltInType
in interface StaticContext
type
- the supposedly built-in type. This will always be a type in the
XS or XDT namespace.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |