Package org.loboevolution.apache.xpath
Class XPathContext
java.lang.Object
org.loboevolution.apache.xml.dtm.DTMManager
org.loboevolution.apache.xpath.XPathContext
Default class for the runtime execution context for XPath.
This class extends DTMManager but does not directly implement it.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DTMManagerThough XPathContext context extends the DTMManager, it really is a proxy for this object, which is the real DTMManager.static final intThe ammount to use for stacks that record information during the recursive execution.Fields inherited from class org.loboevolution.apache.xml.dtm.DTMManager
IDENT_DTM_DEFAULT, IDENT_DTM_NODE_BITS, IDENT_MAX_DTMS, IDENT_NODE_DEFAULT -
Constructor Summary
ConstructorsConstructorDescriptionCreate an XPathContext instance.XPathContext(boolean recursiveVarContext) Create an XPathContext instance. -
Method Summary
Modifier and TypeMethodDescriptioncreateDTMIterator(int whatToShow, DTMFilter filter, boolean entityReferenceExpansion) Create a newDTMIteratorbased only on a whatToShow and a DTMFilter.createDTMIterator(Object xpathCompiler, int pos) createDTMIterator(String xpathString, PrefixResolver presolver) final intGet the current context node.getDTM(int nodeHandle) Get the instance of DTM that "owns" a node handle.Get an instance of a DTM, loaded with the content from the specified source.intgetDTMHandleFromNode(Node node) Given a W3C DOM node, try and return a DTM handle.Return the DTMManager object.final ErrorListenerGet the ErrorListener where errors and warnings are to be reported.final intGet the current location path iterator root.final PrefixResolverGet the current namespace context for the xpath.final intGet the current axes iterator, or return null if none.final URIResolverGet the URIResolver associated with this execution context.final voidPop the current context node.final voidSet the current context node.final voidPop the current namespace context for the xpath.final voidfinal voidPop the last pushed axes iterator.final voidpushCurrentNode(int n) Set the current context node.final voidpushCurrentNodeAndExpression(int cn) Set the current context node and expression node.final voidPush a current namespace context for the xpath.final voidpushPredicatePos(int n) final voidPush a TreeWalker on the stack.voidreset()Reset for new run.voidsetErrorListener(ErrorListener listener) Set the ErrorListener where errors and warnings are to be reported.final voidGet the current namespace context for the xpath.voidsetURIResolver(URIResolver resolver) Set the URIResolver associated with this execution context.Methods inherited from class org.loboevolution.apache.xml.dtm.DTMManager
newInstance
-
Field Details
-
m_dtmManager
Though XPathContext context extends the DTMManager, it really is a proxy for this object, which is the real DTMManager. -
RECURSIONLIMIT
public static final int RECURSIONLIMITThe ammount to use for stacks that record information during the recursive execution.- See Also:
-
-
Constructor Details
-
XPathContext
public XPathContext()Create an XPathContext instance. This is equivalent to calling theXPathContext(boolean)constructor with the valuetrue. -
XPathContext
public XPathContext(boolean recursiveVarContext) Create an XPathContext instance.- Parameters:
recursiveVarContext- Abooleanvalue indicating whether the XPath context needs to support pushing of scopes for variable resolution
-
-
Method Details
-
getDTMManager
Return the DTMManager object. Though XPathContext context extends the DTMManager, it really is a proxy for the real DTMManager. If a caller needs to make a lot of calls to the DTMManager, it is faster if it gets the real one from this function. -
getDTM
Get an instance of a DTM, loaded with the content from the specified source. If the unique flag is true, a new instance will always be returned. Otherwise it is up to the DTMManager to return a new instance or an instance that it already created and may be being used by someone else.(More parameters may eventually need to be added for error handling and entity resolution, and to better control selection of implementations.)
- Specified by:
getDTMin classDTMManager- Parameters:
source- the specification of the source object, which may be null, in which case it is assumed that node construction will take by some other means.unique- true if the returned DTM must be unique, probably because it is going to be mutated.incremental- true if the DTM should be built incrementally, if possible.doIndexing- true if the caller considers it worth it to use indexing schemes.- Returns:
- a non-null DTM reference.
-
getDTM
Get the instance of DTM that "owns" a node handle.- Specified by:
getDTMin classDTMManager- Parameters:
nodeHandle- the nodeHandle.- Returns:
- a non-null DTM reference.
-
getDTMHandleFromNode
Given a W3C DOM node, try and return a DTM handle. Note: calling this may be non-optimal.- Specified by:
getDTMHandleFromNodein classDTMManager- Parameters:
node- Non-null reference to a DOM node.- Returns:
- a valid DTM handle.
-
createDTMIterator
- Specified by:
createDTMIteratorin classDTMManager- Parameters:
xpathCompiler- ??? Somehow we need to pass in a subpart of the expression. I hate to do this with strings, since the larger expression has already been parsed.pos- The position in the expression.- Returns:
- The newly created
DTMIterator.
-
createDTMIterator
- Specified by:
createDTMIteratorin classDTMManager- Parameters:
xpathString- Must be a valid string expressing a LocationPath or a UnionExpr.presolver- An object that can resolve prefixes to namespace URLs.- Returns:
- The newly created
DTMIterator.
-
createDTMIterator
public DTMIterator createDTMIterator(int whatToShow, DTMFilter filter, boolean entityReferenceExpansion) Create a newDTMIteratorbased only on a whatToShow and a DTMFilter. The traversal semantics are defined as the descendant access.Note that DTMIterators may not be an exact match to DOM NodeIterators. They are initialized and used in much the same way as a NodeIterator, but their response to document mutation is not currently defined.
- Specified by:
createDTMIteratorin classDTMManager- Parameters:
whatToShow- This flag specifies which node types may appear in the logical view of the tree presented by the iterator. See the description ofNodeFilterfor the set of possibleSHOW_values.These flags can be combined usingOR.filter- TheNodeFilterto be used with thisDTMFilter, ornullto indicate no filter.entityReferenceExpansion- The value of this flag determines whether entity reference nodes are expanded.- Returns:
- The newly created
DTMIterator.
-
reset
public void reset()Reset for new run. -
getErrorListener
Get the ErrorListener where errors and warnings are to be reported.- Returns:
- A non-null ErrorListener reference.
-
setErrorListener
Set the ErrorListener where errors and warnings are to be reported.- Parameters:
listener- A non-null ErrorListener reference.- Throws:
IllegalArgumentException
-
getURIResolver
Get the URIResolver associated with this execution context.- Returns:
- a URI resolver, which may be null.
-
setURIResolver
Set the URIResolver associated with this execution context.- Parameters:
resolver- the URIResolver to be associated with this execution context, may be null to clear an already set resolver.
-
getCurrentNode
public final int getCurrentNode()Get the current context node.- Returns:
- the current node.
-
pushCurrentNodeAndExpression
public final void pushCurrentNodeAndExpression(int cn) Set the current context node and expression node.- Parameters:
cn- the current node.
-
popCurrentNodeAndExpression
public final void popCurrentNodeAndExpression()Set the current context node. -
pushCurrentNode
public final void pushCurrentNode(int n) Set the current context node.- Parameters:
n- the current node.
-
popCurrentNode
public final void popCurrentNode()Pop the current context node. -
getIteratorRoot
public final int getIteratorRoot()Get the current location path iterator root. -
getPredicatePos
public final int getPredicatePos() -
pushPredicatePos
public final void pushPredicatePos(int n) -
popPredicatePos
public final void popPredicatePos() -
getNamespaceContext
Get the current namespace context for the xpath.- Returns:
- the current prefix resolver for resolving prefixes to namespace URLs.
-
setNamespaceContext
Get the current namespace context for the xpath.- Parameters:
pr- the prefix resolver to be used for resolving prefixes to namespace URLs.
-
pushNamespaceContext
Push a current namespace context for the xpath.- Parameters:
pr- the prefix resolver to be used for resolving prefixes to namespace URLs.
-
popNamespaceContext
public final void popNamespaceContext()Pop the current namespace context for the xpath. -
pushSubContextList
Push a TreeWalker on the stack.- Parameters:
iter- A sub-context AxesWalker.
-
popSubContextList
public final void popSubContextList()Pop the last pushed axes iterator. -
getSubContextList
Get the current axes iterator, or return null if none.- Returns:
- the sub-context node list.
-