FileDocCategorySizeDatePackage
XPathContext.javaAPI DocJava SE 5 API38689Fri Aug 26 14:56:06 BST 2005com.sun.org.apache.xpath.internal

XPathContext

public class XPathContext extends DTMManager
Default class for the runtime execution context for XPath.

This class extends DTMManager but does not directly implement it.

xsl.usage
advanced

Fields Summary
IntStack
m_last_pushed_rtfdtm
private Vector
m_rtfdtm_stack
Stack of cached "reusable" DTMs for Result Tree Fragments. This is a kluge to handle the problem of starting an RTF before the old one is complete. %REVIEW% I'm using a Vector rather than Stack so we can reuse the DTMs if the problem occurs multiple times. I'm not sure that's really a net win versus discarding the DTM and starting a new one... but the retained RTF DTM will have been tail-pruned so should be small.
private int
m_which_rtfdtm
Index of currently active RTF DTM in m_rtfdtm_stack
private SAX2RTFDTM
m_global_rtfdtm
Most recent "reusable" DTM for Global Result Tree Fragments. No stack is required since we're never going to pop these.
protected DTMManager
m_dtmManager
Though XPathContext context extends the DTMManager, it really is a proxy for this object, which is the real DTMManager.
ObjectStack
m_saxLocations
The current stylesheet locator.
private Object
m_owner
The owner context of this XPathContext. In the case of XSLT, this will be a Transformer object.
private Method
m_ownerGetErrorListener
The owner context of this XPathContext. In the case of XSLT, this will be a Transformer object.
private VariableStack
m_variableStacks
The stack of Variable stacks. A VariableStack will be pushed onto this stack for each template invocation.
private SourceTreeManager
m_sourceTreeManager
The source tree manager, which associates Source objects to source tree nodes.
private ErrorListener
m_errorListener
The ErrorListener where errors and warnings are to be reported.
private ErrorListener
m_defaultErrorListener
A default ErrorListener in case our m_errorListener was not specified and our owner either does not have an ErrorListener or has a null one.
private URIResolver
m_uriResolver
The TrAX URI Resolver for resolving URIs from the document(...) function to source tree nodes.
public XMLReader
m_primaryReader
The reader of the primary source tree.
private Stack
m_contextNodeLists
The current context node list.
public static final int
RECURSIONLIMIT
The ammount to use for stacks that record information during the recursive execution.
private IntStack
m_currentNodes
The stack of current node objects. Not to be confused with the current node list. %REVIEW% Note that there are no bounds check and resize for this stack, so if it is blown, it's all over.
private NodeVector
m_iteratorRoots
A stack of the current sub-expression nodes.
private NodeVector
m_predicateRoots
A stack of the current sub-expression nodes.
private IntStack
m_currentExpressionNodes
A stack of the current sub-expression nodes.
private IntStack
m_predicatePos
private ObjectStack
m_prefixResolvers
private Stack
m_axesIteratorStack
Stack of AxesIterators.
XPathExpressionContext
expressionContext
Constructors Summary
public XPathContext()
Create an XPathContext instance.

    m_prefixResolvers.push(null);
    m_currentNodes.push(DTM.NULL);
    m_currentExpressionNodes.push(DTM.NULL);
    m_saxLocations.push(null);
  
public XPathContext(Object owner)
Create an XPathContext instance.

param
owner Value that can be retrieved via the getOwnerObject() method.
see
#getOwnerObject

    m_owner = owner;
    try {
      m_ownerGetErrorListener = m_owner.getClass().getMethod("getErrorListener", new Class[] {});
    }
    catch (NoSuchMethodException nsme) {}
    m_prefixResolvers.push(null);
    m_currentNodes.push(DTM.NULL);
    m_currentExpressionNodes.push(DTM.NULL);
    m_saxLocations.push(null);
  
Methods Summary
private voidassertion(boolean b, java.lang.String msg)
Tell the user of an assertion error, and probably throw an exception.

param
b If false, a TransformerException will be thrown.
param
msg The assertion message, which should be informative.
throws
javax.xml.transform.TransformerException if b is false.

    if (!b) 
    {
      ErrorListener errorHandler = getErrorListener();

      if (errorHandler != null)
      {
        errorHandler.fatalError(
          new TransformerException(
            XSLMessages.createMessage(
              XPATHErrorResources.ER_INCORRECT_PROGRAMMER_ASSERTION,
              new Object[]{ msg }), (SAXSourceLocator)this.getSAXLocator()));
      }
    }
  
public com.sun.org.apache.xml.internal.dtm.DTMIteratorcreateDTMIterator(int whatToShow, com.sun.org.apache.xml.internal.dtm.DTMFilter filter, boolean entityReferenceExpansion)
Create a new DTMIterator based only on a whatToShow and a DTMFilter. The traversal semantics are defined as the descendant access.

param
whatToShow This flag specifies which node types may appear in the logical view of the tree presented by the iterator. See the description of NodeFilter for the set of possible SHOW_ values.These flags can be combined using OR.
param
filter The NodeFilter to be used with this TreeWalker, or null to indicate no filter.
param
entityReferenceExpansion The value of this flag determines whether entity reference nodes are expanded.
return
The newly created NodeIterator.

    return m_dtmManager.createDTMIterator(whatToShow, filter, entityReferenceExpansion);
  
public com.sun.org.apache.xml.internal.dtm.DTMIteratorcreateDTMIterator(int node)
Create a new DTMIterator that holds exactly one node.

param
node The node handle that the DTMIterator will iterate to.
return
The newly created DTMIterator.

    // DescendantIterator iter = new DescendantIterator();
    DTMIterator iter = new com.sun.org.apache.xpath.internal.axes.OneStepIteratorForward(Axis.SELF);
    iter.setRoot(node, this);
    return iter;
    // return m_dtmManager.createDTMIterator(node);
  
public com.sun.org.apache.xml.internal.dtm.DTMIteratorcreateDTMIterator(java.lang.Object xpathCompiler, int pos)
Create a new DTMIterator based on an XPath UnionExpr.

param
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.
param
pos The position in the expression.
return
The newly created DTMIterator.

    return m_dtmManager.createDTMIterator(xpathCompiler, pos);
  
public com.sun.org.apache.xml.internal.dtm.DTMIteratorcreateDTMIterator(java.lang.String xpathString, com.sun.org.apache.xml.internal.utils.PrefixResolver presolver)
Create a new DTMIterator based on an XPath UnionExpr.

param
xpathString Must be a valid string expressing a UnionExpr.
param
presolver An object that can resolve prefixes to namespace URLs.
return
The newly created DTMIterator.

    return m_dtmManager.createDTMIterator(xpathString, presolver);
  
public com.sun.org.apache.xml.internal.dtm.DTMcreateDocumentFragment()
Creates an empty DocumentFragment object.

return
A new DocumentFragment handle.

    return m_dtmManager.createDocumentFragment();
  
public java.util.StackgetAxesIteratorStackStacks()

  
      return m_axesIteratorStack; 
public final intgetContextNode()
Get the current context node.

return
The current context node.

    return this.getCurrentNode();
  
public final com.sun.org.apache.xml.internal.dtm.DTMIteratorgetContextNodeList()
Get the current context node list.

return
the current node list, also refered to here as a context node list.


    if (m_contextNodeLists.size() > 0)
      return (DTMIterator) m_contextNodeLists.peek();
    else
      return null;
  
public java.util.StackgetContextNodeListsStack()

  
      return m_contextNodeLists; 
public final com.sun.org.apache.xml.internal.dtm.DTMIteratorgetContextNodes()
Get the current context node list.

return
An iterator for the current context list, as defined in XSLT.


    try
    {
      DTMIterator cnl = getContextNodeList();

      if (null != cnl)
        return cnl.cloneWithReset();
      else
        return null;  // for now... this might ought to be an empty iterator.
    }
    catch (CloneNotSupportedException cnse)
    {
      return null;  // error reporting?
    }
  
public final intgetCurrentExpressionNode()
Get the current node that is the expression's context (i.e. for current() support).

return
The current sub-expression node.

    return m_currentExpressionNodes.peek();
  
public com.sun.org.apache.xml.internal.utils.IntStackgetCurrentExpressionNodeStack()

  
     
      return m_currentExpressionNodes; 
public final intgetCurrentNode()
Get the current context node.

return
the current node.

    return m_currentNodes.peek();
  
public com.sun.org.apache.xpath.internal.axes.SubContextListgetCurrentNodeList()
Get the current node list as defined by the XSLT spec.

return
the current node list.
xsl.usage
internal

    return m_axesIteratorStack.isEmpty()
           ? null : (SubContextList) m_axesIteratorStack.elementAt(0);
  
public com.sun.org.apache.xml.internal.utils.IntStackgetCurrentNodeStack()

   
//  private NodeVector m_currentNodes = new NodeVector();
  
     return m_currentNodes; 
public com.sun.org.apache.xml.internal.dtm.DTMgetDTM(javax.xml.transform.Source source, boolean unique, com.sun.org.apache.xml.internal.dtm.DTMWSFilter wsfilter, boolean incremental, boolean doIndexing)
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. (I think more parameters will need to be added for error handling, and entity resolution).

param
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.
param
unique true if the returned DTM must be unique, probably because it is going to be mutated.
param
whiteSpaceFilter Enables filtering of whitespace nodes, and may be null.
param
incremental true if the construction should try and be incremental.
param
doIndexing true if the caller considers it worth it to use indexing schemes.
return
a non-null DTM reference.

    return m_dtmManager.getDTM(source, unique, wsfilter, 
                               incremental, doIndexing);
  
public com.sun.org.apache.xml.internal.dtm.DTMgetDTM(int nodeHandle)
Get an instance of a DTM that "owns" a node handle.

param
nodeHandle the nodeHandle.
return
a non-null DTM reference.

    return m_dtmManager.getDTM(nodeHandle);
  
public intgetDTMHandleFromNode(org.w3c.dom.Node node)
Given a W3C DOM node, try and return a DTM handle. Note: calling this may be non-optimal.

param
node Non-null reference to a DOM node.
return
a valid DTM handle.

    return m_dtmManager.getDTMHandleFromNode(node);
  
public intgetDTMIdentity(com.sun.org.apache.xml.internal.dtm.DTM dtm)
%TBD% Doc

    return m_dtmManager.getDTMIdentity(dtm);
  
public com.sun.org.apache.xml.internal.dtm.DTMManagergetDTMManager()
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.

  
                                                      
     
   
     return m_dtmManager;
   
public final javax.xml.transform.ErrorListenergetErrorListener()
Get the ErrorListener where errors and warnings are to be reported.

return
A non-null ErrorListener reference.


    if (null != m_errorListener)
        return m_errorListener;

    ErrorListener retval = null;

    try {
      if (null != m_ownerGetErrorListener)
        retval = (ErrorListener) m_ownerGetErrorListener.invoke(m_owner, new Object[] {});
    }
    catch (Exception e) {}

    if (null == retval)
    {
      if (null == m_defaultErrorListener) 
        m_defaultErrorListener = new com.sun.org.apache.xml.internal.utils.DefaultErrorHandler();
      retval = m_defaultErrorListener;
    }

    return retval;
  
public com.sun.org.apache.xalan.internal.extensions.ExpressionContextgetExpressionContext()
The the expression context for extensions for this context.

return
An object that implements the ExpressionContext.

  
                      
    
  
    return expressionContext;
  
public com.sun.org.apache.xml.internal.dtm.DTMgetGlobalRTFDTM()
Get a DTM to be used as a container for a global Result Tree Fragment. This will always be an instance of (derived from? equivalent to?) SAX2DTM, since each RTF is constructed by temporarily redirecting our SAX output to it. It may be a single DTM containing for multiple fragments, if the implementation supports that. Note: The distinction between this method and getRTFDTM() is that the latter allocates space from the dynamic variable stack (m_rtfdtm_stack), which may be pruned away again as the templates which defined those variables are exited. Global variables may be bound late (see XUnresolvedVariable), and never want to be discarded, hence we need to allocate them separately and don't actually need a stack to track them.

return
a non-null DTM reference.

  	// We probably should _NOT_ be applying whitespace filtering at this stage!
  	//
  	// Some magic has been applied in DTMManagerDefault to recognize this set of options
  	// and generate an instance of DTM which can contain multiple documents
  	// (SAX2RTFDTM). Perhaps not the optimal way of achieving that result, but
  	// I didn't want to change the manager API at this time, or expose 
  	// too many dependencies on its internals. (Ideally, I'd like to move
  	// isTreeIncomplete all the way up to DTM, so we wouldn't need to explicitly
  	// specify the subclass here.)

	// If it doesn't exist, or if the one already existing is in the middle of
	// being constructed, we need to obtain a new DTM to write into. I'm not sure
	// the latter will ever arise, but I'd rather be just a bit paranoid..
	if( m_global_rtfdtm==null || m_global_rtfdtm.isTreeIncomplete() )
	{
  		m_global_rtfdtm=(SAX2RTFDTM)m_dtmManager.getDTM(null,true,null,false,false);
	}
    return m_global_rtfdtm;
  
public final intgetIteratorRoot()
Get the current location path iterator root.

    return m_iteratorRoots.peepOrNull();
  
public final com.sun.org.apache.xml.internal.utils.PrefixResolvergetNamespaceContext()
Get the current namespace context for the xpath.

return
the current prefix resolver for resolving prefixes to namespace URLs.


                                 
     
  
    return (PrefixResolver) m_prefixResolvers.peek();
  
public java.lang.ObjectgetOwnerObject()
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.

return
The owner object passed into the constructor, or null.

    return m_owner;
  
public final intgetPredicatePos()

  
     
  
    return m_predicatePos.peek();
  
public final intgetPredicateRoot()
Get the current predicate root.

    return m_predicateRoots.peepOrNull();
  
public final org.xml.sax.XMLReadergetPrimaryReader()
Get primary XMLReader associated with this execution context.

return
The reader of the primary source tree.

    return m_primaryReader;
  
public com.sun.org.apache.xml.internal.dtm.DTMgetRTFDTM()
Get a DTM to be used as a container for a dynamic Result Tree Fragment. This will always be an instance of (derived from? equivalent to?) SAX2DTM, since each RTF is constructed by temporarily redirecting our SAX output to it. It may be a single DTM containing for multiple fragments, if the implementation supports that.

return
a non-null DTM reference.

  	SAX2RTFDTM rtfdtm;

  	// We probably should _NOT_ be applying whitespace filtering at this stage!
  	//
  	// Some magic has been applied in DTMManagerDefault to recognize this set of options
  	// and generate an instance of DTM which can contain multiple documents
  	// (SAX2RTFDTM). Perhaps not the optimal way of achieving that result, but
  	// I didn't want to change the manager API at this time, or expose 
  	// too many dependencies on its internals. (Ideally, I'd like to move
  	// isTreeIncomplete all the way up to DTM, so we wouldn't need to explicitly
  	// specify the subclass here.)

	if(m_rtfdtm_stack==null)
	{
		m_rtfdtm_stack=new Vector();
  		rtfdtm=(SAX2RTFDTM)m_dtmManager.getDTM(null,true,null,false,false);
    m_rtfdtm_stack.addElement(rtfdtm);
		++m_which_rtfdtm;
	}
	else if(m_which_rtfdtm<0)
	{
		rtfdtm=(SAX2RTFDTM)m_rtfdtm_stack.elementAt(++m_which_rtfdtm);
	}
	else
	{
		rtfdtm=(SAX2RTFDTM)m_rtfdtm_stack.elementAt(m_which_rtfdtm);
  		
	  	// It might already be under construction -- the classic example would be
 	 	// an xsl:variable which uses xsl:call-template as part of its value. To
  		// handle this recursion, we have to start a new RTF DTM, pushing the old
  		// one onto a stack so we can return to it. This is not as uncommon a case
  		// as we might wish, unfortunately, as some folks insist on coding XSLT
  		// as if it were a procedural language...
  		if(rtfdtm.isTreeIncomplete())
	  	{
	  		if(++m_which_rtfdtm < m_rtfdtm_stack.size())
				rtfdtm=(SAX2RTFDTM)m_rtfdtm_stack.elementAt(m_which_rtfdtm);
	  		else
	  		{
		  		rtfdtm=(SAX2RTFDTM)m_dtmManager.getDTM(null,true,null,false,false);
          m_rtfdtm_stack.addElement(rtfdtm); 	
	  		}
 	 	}
	}
		
    return rtfdtm;
  
public javax.xml.transform.SourceLocatorgetSAXLocator()
Get the current locater in the stylesheet.

return
The location within the stylesheet, or null if not known.

    return (SourceLocator) m_saxLocations.peek();
  
public final SourceTreeManagergetSourceTreeManager()
Get the SourceTreeManager associated with this execution context.

return
the SourceTreeManager associated with this execution context.


                     
     
  
    return m_sourceTreeManager;
  
public com.sun.org.apache.xpath.internal.axes.SubContextListgetSubContextList()
Get the current axes iterator, or return null if none.

return
the sub-context node list.
xsl.usage
internal

    return m_axesIteratorStack.isEmpty()
           ? null : (SubContextList) m_axesIteratorStack.peek();
  
public final javax.xml.transform.URIResolvergetURIResolver()
Get the URIResolver associated with this execution context.

return
a URI resolver, which may be null.

    return m_uriResolver;
  
public final com.sun.org.apache.xpath.internal.VariableStackgetVarStack()
Get the variable stack, which is in charge of variables and parameters.

return
the variable stack, which should not be null.


                          
     
  
    return m_variableStacks;
  
public final voidpopContextNodeList()
Pop the current context node list.

xsl.usage
internal

  	if(m_contextNodeLists.isEmpty())
  	  System.err.println("Warning: popContextNodeList when stack is empty!");
  	else
      m_contextNodeLists.pop();
  
public final voidpopCurrentExpressionNode()
Pop the current node that is the expression's context (i.e. for current() support).

    m_currentExpressionNodes.quickPop(1);
  
public final voidpopCurrentNode()
Pop the current context node.

    m_currentNodes.quickPop(1);
  
public final voidpopCurrentNodeAndExpression()
Set the current context node.

    m_currentNodes.quickPop(1);
    m_currentExpressionNodes.quickPop(1);
  
public final voidpopExpressionState()
Pop the current context node, expression node, and prefix resolver.

    m_currentNodes.quickPop(1);
    m_currentExpressionNodes.quickPop(1);
    m_prefixResolvers.pop();
  
public final voidpopIteratorRoot()
Pop the current location path iterator root.

    m_iteratorRoots.popQuick();
  
public final voidpopNamespaceContext()
Pop the current namespace context for the xpath.

    m_prefixResolvers.pop();
  
public final voidpopPredicatePos()

    m_predicatePos.pop();
  
public final voidpopPredicateRoot()
Pop the current predicate root.

    m_predicateRoots.popQuick();
  
public voidpopRTFContext()
Pop the RTFDTM's context mark. This discards any RTFs added after the last mark was set. If there is no RTF DTM, there's nothing to pop so this becomes a no-op. If pushes were issued before this was called, we count on the fact that popRewindMark is defined such that overpopping just resets to empty. Complicating factor: We need to handle the case of popping back to a previous RTF DTM, if one of the weird produce-an-RTF-to-build-an-RTF cases arose. Basically: If pop says this DTM is now empty, then return to the previous if one exists, in whatever state we left it in. UGLY, but hopefully the situation which forces us to consider this will arise exceedingly rarely.

  	int previous=m_last_pushed_rtfdtm.pop();
  	if(null==m_rtfdtm_stack)
  		return;
  
  	if(m_which_rtfdtm==previous)
  	{
  		if(previous>=0) // guard against none-active
  		{
	  		boolean isEmpty=((SAX2RTFDTM)(m_rtfdtm_stack.elementAt(previous))).popRewindMark();
  		}
  	}
  	else while(m_which_rtfdtm!=previous)
  	{
  		// Empty each DTM before popping, so it's ready for reuse
  		// _DON'T_ pop the previous, since it's still open (which is why we
  		// stacked up more of these) and did not receive a mark.
  		boolean isEmpty=((SAX2RTFDTM)(m_rtfdtm_stack.elementAt(m_which_rtfdtm))).popRewindMark();
  		--m_which_rtfdtm; 
  	}
  
public voidpopSAXLocator()
Pop the current locater.

    m_saxLocations.pop();
  
public final voidpopSubContextList()
Pop the last pushed axes iterator.

xsl.usage
internal

    m_axesIteratorStack.pop();
  
public final voidpushContextNodeList(com.sun.org.apache.xml.internal.dtm.DTMIterator nl)
Set the current context node list.

param
nl the current node list, also refered to here as a context node list.
xsl.usage
internal

    m_contextNodeLists.push(nl);
  
public final voidpushCurrentExpressionNode(int n)
Set the current node that is the expression's context (i.e. for current() support).

param
n The sub-expression node to be current.

    m_currentExpressionNodes.push(n);
  
public final voidpushCurrentNode(int n)
Set the current context node.

param
n the current node.

    m_currentNodes.push(n);
  
public final voidpushCurrentNodeAndExpression(int cn, int en)
Set the current context node and expression node.

param
cn the current node.
param
en the sub-expression context node.

    m_currentNodes.push(cn);
    m_currentExpressionNodes.push(cn);
  
public final voidpushExpressionState(int cn, int en, com.sun.org.apache.xml.internal.utils.PrefixResolver nc)
Push the current context node, expression node, and prefix resolver.

param
cn the current node.
param
en the sub-expression context node.
param
nc the namespace context (prefix resolver.

    m_currentNodes.push(cn);
    m_currentExpressionNodes.push(cn);
    m_prefixResolvers.push(nc);
  
public final voidpushIteratorRoot(int n)
Set the current location path iterator root.

    m_iteratorRoots.push(n);
  
public final voidpushNamespaceContext(com.sun.org.apache.xml.internal.utils.PrefixResolver pr)
Push a current namespace context for the xpath.

param
pr the prefix resolver to be used for resolving prefixes to namespace URLs.

    m_prefixResolvers.push(pr);
  
public final voidpushNamespaceContextNull()
Just increment the namespace contest stack, so that setNamespaceContext can be used on the slot.

    m_prefixResolvers.push(null);
  
public final voidpushPredicatePos(int n)

    m_predicatePos.push(n);
  
public final voidpushPredicateRoot(int n)
Set the current predicate root.

    m_predicateRoots.push(n);
  
public voidpushRTFContext()
Push the RTFDTM's context mark, to allows discarding RTFs added after this point. (If it doesn't exist we don't push, since we might still be able to get away with not creating it. That requires that excessive pops be harmless.)

  	m_last_pushed_rtfdtm.push(m_which_rtfdtm);
  	if(null!=m_rtfdtm_stack)
	  	((SAX2RTFDTM)(getRTFDTM())).pushRewindMark();
  
public voidpushSAXLocator(javax.xml.transform.SourceLocator location)
Set the current locater in the stylesheet.

param
location The location within the stylesheet.

    m_saxLocations.push(location);
  
public voidpushSAXLocatorNull()
Push a slot on the locations stack so that setSAXLocator can be repeatedly called.

param
location The location within the stylesheet.

    m_saxLocations.push(null);
  
public final voidpushSubContextList(com.sun.org.apache.xpath.internal.axes.SubContextList iter)
Push a TreeWalker on the stack.

param
iter A sub-context AxesWalker.
xsl.usage
internal

    m_axesIteratorStack.push(iter);
  
public booleanrelease(com.sun.org.apache.xml.internal.dtm.DTM dtm, boolean shouldHardDelete)
Release a DTM either to a lru pool, or completely remove reference. DTMs without system IDs are always hard deleted. State: experimental.

param
dtm The DTM to be released.
param
shouldHardDelete True if the DTM should be removed no matter what.
return
true if the DTM was removed, false if it was put back in a lru pool.

    // %REVIEW% If it's a DTM which may contain multiple Result Tree
    // Fragments, we can't discard it unless we know not only that it
    // is empty, but that the XPathContext itself is going away. So do
    // _not_ accept the request. (May want to do it as part of
    // reset(), though.)
    if(m_rtfdtm_stack!=null && m_rtfdtm_stack.contains(dtm))
    {
      return false;
    }
  	
    return m_dtmManager.release(dtm, shouldHardDelete);
  
public voidreset()
Reset for new run.

  	// These couldn't be disposed of earlier (see comments in release()); zap them now.
  	if(m_rtfdtm_stack!=null)
  		 for (java.util.Enumeration e = m_rtfdtm_stack.elements() ; e.hasMoreElements() ;) 
  		 	m_dtmManager.release((DTM)e.nextElement(), true);

    m_rtfdtm_stack=null; // drop our references too
    m_which_rtfdtm=-1;
    
    if(m_global_rtfdtm!=null)
  		 	m_dtmManager.release(m_global_rtfdtm,true);
    m_global_rtfdtm=null;
  	
    m_dtmManager = DTMManager.newInstance(
                   com.sun.org.apache.xpath.internal.objects.XMLStringFactoryImpl.getFactory());
                   
    m_saxLocations.removeAllElements();   
	m_axesIteratorStack.removeAllElements();
	m_contextNodeLists.removeAllElements();
	m_currentExpressionNodes.removeAllElements();
	m_currentNodes.removeAllElements();
	m_iteratorRoots.RemoveAllNoClear();
	m_predicatePos.removeAllElements();
	m_predicateRoots.RemoveAllNoClear();
	m_prefixResolvers.removeAllElements();
	
	m_prefixResolvers.push(null);
    m_currentNodes.push(DTM.NULL);
    m_currentExpressionNodes.push(DTM.NULL);
    m_saxLocations.push(null);
  
public voidsetAxesIteratorStackStacks(java.util.Stack s)

 m_axesIteratorStack = s; 
public voidsetContextNodeListsStack(java.util.Stack s)

 m_contextNodeLists = s; 
public voidsetCurrentExpressionNodeStack(com.sun.org.apache.xml.internal.utils.IntStack nv)

 m_currentExpressionNodes = nv; 
public voidsetCurrentNodeStack(com.sun.org.apache.xml.internal.utils.IntStack nv)

 m_currentNodes = nv; 
public voidsetErrorListener(javax.xml.transform.ErrorListener listener)
Set the ErrorListener where errors and warnings are to be reported.

param
listener A non-null ErrorListener reference.

    if (listener == null) 
      throw new IllegalArgumentException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, null)); //"Null error handler");
    m_errorListener = listener;
  
public final voidsetNamespaceContext(com.sun.org.apache.xml.internal.utils.PrefixResolver pr)
Get the current namespace context for the xpath.

param
pr the prefix resolver to be used for resolving prefixes to namespace URLs.

    m_prefixResolvers.setTop(pr);
  
public voidsetPrimaryReader(org.xml.sax.XMLReader reader)
Set primary XMLReader associated with this execution context.

param
reader The reader of the primary source tree.

    m_primaryReader = reader;
  
public voidsetSAXLocator(javax.xml.transform.SourceLocator location)
Set the current locater in the stylesheet.

param
location The location within the stylesheet.


                   
     
  
    m_saxLocations.setTop(location);
  
public voidsetSourceTreeManager(SourceTreeManager mgr)
Set the SourceTreeManager associated with this execution context.

param
mgr the SourceTreeManager to be associated with this execution context.

    m_sourceTreeManager = mgr;
  
public voidsetURIResolver(javax.xml.transform.URIResolver resolver)
Set the URIResolver associated with this execution context.

param
resolver the URIResolver to be associated with this execution context, may be null to clear an already set resolver.

    m_uriResolver = resolver;
  
public final voidsetVarStack(com.sun.org.apache.xpath.internal.VariableStack varStack)
Get the variable stack, which is in charge of variables and parameters.

param
varStack non-null reference to the variable stack.

    m_variableStacks = varStack;