org.apache.xpath
Class XPathContext

java.lang.Object
  |
  +--org.apache.xpath.XPathContext

public class XPathContext
extends java.lang.Object
implements ExpressionContext

**For advanced use only** Default class for the runtime execution context for XPath.


Field Summary
 XMLReader m_primaryReader
          The reader of the primary source tree.
 
Constructor Summary
XPathContext()
          Create an XPathContext instance.
XPathContext(java.lang.Object owner)
          Create an XPathContext instance.
 
Method Summary
 java.util.Stack getAxesIteratorStackStacks()
           
 Node getContextNode()
          Get the current context node.
 ContextNodeList getContextNodeList()
          Get the current context node list.
 java.util.Stack getContextNodeListsStack()
           
 NodeIterator getContextNodes()
          Get the current context node list.
 Node getCurrentExpressionNode()
          Get the current node that is the expression's context (i.e.
 NodeVector getCurrentExpressionNodeStack()
           
 Node getCurrentNode()
          Get the current context node.
 NodeVector getCurrentNodeStack()
           
 DOMHelper getDOMHelper()
          Get the DOMHelper associated with this execution context.
 ErrorListener getErrorListener()
          Get the ErrorListener where errors and warnings are to be reported.
 ExtensionsTable getExtensionsTable()
          Get the extensions table object.
 PrefixResolver getNamespaceContext()
          Get the current namespace context for the xpath.
 java.lang.Object getOwnerObject()
          Get the "owner" context of this context, which should be, in the case of XSLT, the Transformer object.
 XMLReader getPrimaryReader()
          Get primary XMLReader associated with this execution context.
 SourceLocator getSAXLocator()
          Get the current locater in the stylesheet.
 SourceTreeManager getSourceTreeManager()
          Get the SourceTreeManager associated with this execution context.
 SubContextList getSubContextList()
          **For internal use only** Get the current axes iterator, or return null if none.
 URIResolver getURIResolver()
          Get the URIResolver associated with this execution context.
 XObject getVariable(QName qname)
          Given a name, locate a variable in the current context, and return the Object.
 VariableStack getVarStack()
          Get the variable stack, which is in charge of variables and parameters.
 void popContextNodeList()
          **For internal use only** Pop the current context node list.
 void popCurrentExpressionNode()
          Pop the current node that is the expression's context (i.e.
 void popCurrentNode()
          Pop the current context node.
 void popCurrentNodeAndExpression()
          Set the current context node.
 void popSubContextList()
          **For internal use only** Pop the last pushed axes iterator.
 void pushContextNodeList(ContextNodeList nl)
          **For internal use only** Set the current context node list.
 void pushCurrentExpressionNode(Node n)
          Set the current node that is the expression's context (i.e.
 void pushCurrentNode(Node n)
          Set the current context node.
 void pushCurrentNodeAndExpression(Node cn, Node en)
          Set the current context node and expression node.
 void pushSubContextList(SubContextList iter)
          **For internal use only** Push a TreeWalker on the stack.
 void reset()
          Reset for new run.
 void setAxesIteratorStackStacks(java.util.Stack s)
           
 void setContextNodeListsStack(java.util.Stack s)
           
 void setCurrentExpressionNodeStack(NodeVector nv)
           
 void setCurrentNodeStack(NodeVector nv)
           
 void setDOMHelper(DOMHelper helper)
          Set the DOMHelper associated with this execution context.
 void setErrorListener(ErrorListener listener)
          Set the ErrorListener where errors and warnings are to be reported.
 void setNamespaceContext(PrefixResolver pr)
          Get the current namespace context for the xpath.
 void setPrimaryReader(XMLReader reader)
          Set primary XMLReader associated with this execution context.
 void setSAXLocator(SourceLocator location)
          Set the current locater in the stylesheet.
 void setSourceTreeManager(SourceTreeManager mgr)
          Set the SourceTreeManager associated with this execution context.
 void setURIResolver(URIResolver resolver)
          Set the URIResolver associated with this execution context.
 void setVarStack(VariableStack varStack)
          Get the variable stack, which is in charge of variables and parameters.
 double toNumber(Node n)
          Get the value of a node as a number.
 java.lang.String toString(Node n)
          Get the value of a node as a string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_primaryReader

public XMLReader m_primaryReader
The reader of the primary source tree.
Constructor Detail

XPathContext

public XPathContext()
Create an XPathContext instance.

XPathContext

public XPathContext(java.lang.Object owner)
Create an XPathContext instance.
Parameters:
owner - Value that can be retrieved via the getOwnerObject() method.
See Also:
getOwnerObject()
Method Detail

reset

public void reset()
Reset for new run.

setSAXLocator

public void setSAXLocator(SourceLocator location)
Set the current locater in the stylesheet.
Parameters:
location - The location within the stylesheet.

getSAXLocator

public SourceLocator getSAXLocator()
Get the current locater in the stylesheet.
Returns:
The location within the stylesheet, or null if not known.

getOwnerObject

public java.lang.Object getOwnerObject()
Get the "owner" context of this context, which should be, in the case of XSLT, the Transformer object. This is needed so that XSLT functions can get the Transformer.
Returns:
The owner object passed into the constructor, or null.

getExtensionsTable

public ExtensionsTable getExtensionsTable()
Get the extensions table object.
Returns:
The extensions table.

getVarStack

public VariableStack getVarStack()
Get the variable stack, which is in charge of variables and parameters.
Returns:
the variable stack, which should not be null.

setVarStack

public void setVarStack(VariableStack varStack)
Get the variable stack, which is in charge of variables and parameters.
Parameters:
varStack - non-null reference to the variable stack.

getVariable

public XObject getVariable(QName qname)
                    throws TransformerException
Given a name, locate a variable in the current context, and return the Object.
Parameters:
qname - The qualified name of a variable.
Returns:
reference to variable, or null if not found.
Throws:
TransformerException -  

getDOMHelper

public final DOMHelper getDOMHelper()
Get the DOMHelper associated with this execution context.
Returns:
non-null reference to a DOM helper.

setDOMHelper

public void setDOMHelper(DOMHelper helper)
Set the DOMHelper associated with this execution context.
Parameters:
helper - reference to a dom helper to be associated with this execution context.

getSourceTreeManager

public final SourceTreeManager getSourceTreeManager()
Get the SourceTreeManager associated with this execution context.
Returns:
the SourceTreeManager associated with this execution context.

setSourceTreeManager

public void setSourceTreeManager(SourceTreeManager mgr)
Set the SourceTreeManager associated with this execution context.
Parameters:
mgr - the SourceTreeManager to be associated with this execution context.

getErrorListener

public final ErrorListener getErrorListener()
Get the ErrorListener where errors and warnings are to be reported.
Returns:
A non-null ErrorListener reference.

setErrorListener

public void setErrorListener(ErrorListener listener)
                      throws java.lang.IllegalArgumentException
Set the ErrorListener where errors and warnings are to be reported.
Parameters:
listener - A non-null ErrorListener reference.

getURIResolver

public final URIResolver getURIResolver()
Get the URIResolver associated with this execution context.
Returns:
a URI resolver, which may be null.

setURIResolver

public void setURIResolver(URIResolver resolver)
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.

getPrimaryReader

public final XMLReader getPrimaryReader()
Get primary XMLReader associated with this execution context.
Returns:
The reader of the primary source tree.

setPrimaryReader

public void setPrimaryReader(XMLReader reader)
Set primary XMLReader associated with this execution context.
Parameters:
reader - The reader of the primary source tree.

getContextNodeListsStack

public java.util.Stack getContextNodeListsStack()

setContextNodeListsStack

public void setContextNodeListsStack(java.util.Stack s)

getContextNodeList

public final ContextNodeList getContextNodeList()
Get the current context node list.
Returns:
the current node list, also refered to here as a context node list.

pushContextNodeList

public final void pushContextNodeList(ContextNodeList nl)
**For internal use only** Set the current context node list.
Parameters:
nl - the current node list, also refered to here as a context node list.

popContextNodeList

public final void popContextNodeList()
**For internal use only** Pop the current context node list.

getCurrentNodeStack

public NodeVector getCurrentNodeStack()

setCurrentNodeStack

public void setCurrentNodeStack(NodeVector nv)

getCurrentNode

public final Node getCurrentNode()
Get the current context node.
Returns:
the current node.

pushCurrentNodeAndExpression

public final void pushCurrentNodeAndExpression(Node cn,
                                               Node en)
Set the current context node and expression node.
Parameters:
cn - the current node.
en - the sub-expression context node.

popCurrentNodeAndExpression

public final void popCurrentNodeAndExpression()
Set the current context node.

pushCurrentNode

public final void pushCurrentNode(Node n)
Set the current context node.
Parameters:
n - the current node.

popCurrentNode

public final void popCurrentNode()
Pop the current context node.

getCurrentExpressionNodeStack

public NodeVector getCurrentExpressionNodeStack()

setCurrentExpressionNodeStack

public void setCurrentExpressionNodeStack(NodeVector nv)

getCurrentExpressionNode

public final Node getCurrentExpressionNode()
Get the current node that is the expression's context (i.e. for current() support).
Returns:
The current sub-expression node.

pushCurrentExpressionNode

public final void pushCurrentExpressionNode(Node n)
Set the current node that is the expression's context (i.e. for current() support).
Parameters:
n - The sub-expression node to be current.

popCurrentExpressionNode

public final void popCurrentExpressionNode()
Pop the current node that is the expression's context (i.e. for current() support).

getNamespaceContext

public final PrefixResolver getNamespaceContext()
Get the current namespace context for the xpath.
Returns:
the current prefix resolver for resolving prefixes to namespace URLs.

setNamespaceContext

public final void setNamespaceContext(PrefixResolver pr)
Get the current namespace context for the xpath.
Parameters:
pr - the prefix resolver to be used for resolving prefixes to namespace URLs.

getAxesIteratorStackStacks

public java.util.Stack getAxesIteratorStackStacks()

setAxesIteratorStackStacks

public void setAxesIteratorStackStacks(java.util.Stack s)

pushSubContextList

public final void pushSubContextList(SubContextList iter)
**For internal use only** Push a TreeWalker on the stack.
Parameters:
iter - A sub-context AxesWalker.

popSubContextList

public final void popSubContextList()
**For internal use only** Pop the last pushed axes iterator.

getSubContextList

public SubContextList getSubContextList()
**For internal use only** Get the current axes iterator, or return null if none.
Returns:
the sub-context node list.

getContextNode

public final Node getContextNode()
Get the current context node.
Specified by:
getContextNode in interface ExpressionContext
Returns:
The current context node.

getContextNodes

public final NodeIterator getContextNodes()
Get the current context node list.
Specified by:
getContextNodes in interface ExpressionContext
Returns:
An iterator for the current context list, as defined in XSLT.

toNumber

public final double toNumber(Node n)
Get the value of a node as a number.
Specified by:
toNumber in interface ExpressionContext
Parameters:
n - Node to be converted to a number. May be null.
Returns:
value of n as a number.

toString

public final java.lang.String toString(Node n)
Get the value of a node as a string.
Specified by:
toString in interface ExpressionContext
Parameters:
n - Node to be converted to a string. May be null.
Returns:
value of n as a string, or an empty string if n is null.


Copyright © 2000 Apache XML Project. All Rights Reserved.