Java Code Examples for org.apache.xpath.XPathContext#pushCurrentNode()

The following examples show how to use org.apache.xpath.XPathContext#pushCurrentNode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransformerImpl.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * Execute each of the children of a template element.  This method
 * is only for extension use.
 *
 * @param elem The ElemTemplateElement that contains the children
 * that should execute.
 * NEEDSDOC @param context
 * @param mode The current mode.
 * @param handler The ContentHandler to where the result events
 * should be fed.
 *
 * @throws TransformerException
 * @xsl.usage advanced
 */
public void executeChildTemplates(
        ElemTemplateElement elem, org.w3c.dom.Node context, QName mode, ContentHandler handler)
          throws TransformerException
{

  XPathContext xctxt = m_xcontext;

  try
  {
    if(null != mode)
      pushMode(mode);
    xctxt.pushCurrentNode(xctxt.getDTMHandleFromNode(context));
    executeChildTemplates(elem, handler);
  }
  finally
  {
    xctxt.popCurrentNode();
    
    // I'm not sure where or why this was here.  It is clearly in 
    // error though, without a corresponding pushMode().
    if (null != mode)
      popMode();
  }
}
 
Example 2
Source File: StepPattern.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * Get the match score of the given node.
 *
 * @param xctxt The XPath runtime context.
 * @param context The node to be tested.
 *
 * @return {@link org.apache.xpath.patterns.NodeTest#SCORE_NODETEST},
 *         {@link org.apache.xpath.patterns.NodeTest#SCORE_NONE},
 *         {@link org.apache.xpath.patterns.NodeTest#SCORE_NSWILD},
 *         {@link org.apache.xpath.patterns.NodeTest#SCORE_QNAME}, or
 *         {@link org.apache.xpath.patterns.NodeTest#SCORE_OTHER}.
 *
 * @throws javax.xml.transform.TransformerException
 */
public double getMatchScore(XPathContext xctxt, int context)
        throws javax.xml.transform.TransformerException
{

  xctxt.pushCurrentNode(context);
  xctxt.pushCurrentExpressionNode(context);

  try
  {
    XObject score = execute(xctxt);

    return score.num();
  }
  finally
  {
    xctxt.popCurrentNode();
    xctxt.popCurrentExpressionNode();
  }

  // return XPath.MATCH_SCORE_NONE;
}
 
Example 3
Source File: ElemWithParam.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Get the XObject representation of the variable.
 *
 * @param transformer non-null reference to the the current transform-time state.
 * @param sourceNode non-null reference to the <a href="http://www.w3.org/TR/xslt#dt-current-node">current source node</a>.
 *
 * @return the XObject representation of the variable.
 *
 * @throws TransformerException
 */
public XObject getValue(TransformerImpl transformer, int sourceNode)
        throws TransformerException
{

  XObject var;
  XPathContext xctxt = transformer.getXPathContext();

  xctxt.pushCurrentNode(sourceNode);

  try
  {
    if (null != m_selectPattern)
    {
      var = m_selectPattern.execute(xctxt, sourceNode, this);

      var.allowDetachToRelease(false);
    }
    else if (null == getFirstChildElem())
    {
      var = XString.EMPTYSTRING;
    }
    else
    {

      // Use result tree fragment
      int df = transformer.transformToRTF(this);

      var = new XRTreeFrag(df, xctxt, this);
    }
  }
  finally
  {
    xctxt.popCurrentNode();
  }

  return var;
}
 
Example 4
Source File: StepPattern.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Execute the match pattern step relative to another step.
 *
 *
 * @param xctxt The XPath runtime context.
 * @param dtm The DTM of the current node.
 * @param currentNode The current node context.
 *
 * @return {@link org.apache.xpath.patterns.NodeTest#SCORE_NODETEST},
 *         {@link org.apache.xpath.patterns.NodeTest#SCORE_NONE},
 *         {@link org.apache.xpath.patterns.NodeTest#SCORE_NSWILD},
 *         {@link org.apache.xpath.patterns.NodeTest#SCORE_QNAME}, or
 *         {@link org.apache.xpath.patterns.NodeTest#SCORE_OTHER}.
 *
 * @throws javax.xml.transform.TransformerException
 */
protected final XObject executeRelativePathPattern(
        XPathContext xctxt, DTM dtm, int currentNode)
          throws javax.xml.transform.TransformerException
{

  XObject score = NodeTest.SCORE_NONE;
  int context = currentNode;
  DTMAxisTraverser traverser;

  traverser = dtm.getAxisTraverser(m_axis);

  for (int relative = traverser.first(context); DTM.NULL != relative;
          relative = traverser.next(context, relative))
  {
    try
    {
      xctxt.pushCurrentNode(relative);

      score = execute(xctxt);

      if (score != NodeTest.SCORE_NONE)
        break;
    }
    finally
    {
      xctxt.popCurrentNode();
    }
  }

  return score;
}
 
Example 5
Source File: UnionChildIterator.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Test whether a specified node is visible in the logical view of a
 * TreeWalker or NodeIterator. This function will be called by the
 * implementation of TreeWalker and NodeIterator; it is not intended to
 * be called directly from user code.
 * @param n  The node to check to see if it passes the filter or not.
 * @return  a constant to determine whether the node is accepted,
 *   rejected, or skipped, as defined  above .
 */
public short acceptNode(int n)
{
  XPathContext xctxt = getXPathContext();
  try
  {
    xctxt.pushCurrentNode(n);
    for (int i = 0; i < m_nodeTests.length; i++)
    {
      PredicatedNodeTest pnt = m_nodeTests[i];
      XObject score = pnt.execute(xctxt, n);
      if (score != NodeTest.SCORE_NONE)
      {
        // Note that we are assuming there are no positional predicates!
        if (pnt.getPredicateCount() > 0)
        {
          if (pnt.executePredicates(n, xctxt))
            return DTMIterator.FILTER_ACCEPT;
        }
        else
          return DTMIterator.FILTER_ACCEPT;

      }
    }
  }
  catch (javax.xml.transform.TransformerException se)
  {

    // TODO: Fix this.
    throw new RuntimeException(se.getMessage());
  }
  finally
  {
    xctxt.popCurrentNode();
  }
  return DTMIterator.FILTER_SKIP;
}
 
Example 6
Source File: PredicatedNodeTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 *  Test whether a specified node is visible in the logical view of a
 * TreeWalker or NodeIterator. This function will be called by the
 * implementation of TreeWalker and NodeIterator; it is not intended to
 * be called directly from user code.
 * @param n  The node to check to see if it passes the filter or not.
 * @return  a constant to determine whether the node is accepted,
 *   rejected, or skipped, as defined  above .
 */
public short acceptNode(int n)
{

  XPathContext xctxt = m_lpi.getXPathContext();

  try
  {
    xctxt.pushCurrentNode(n);

    XObject score = execute(xctxt, n);

    // System.out.println("\n::acceptNode - score: "+score.num()+"::");
    if (score != NodeTest.SCORE_NONE)
    {
      if (getPredicateCount() > 0)
      {
        countProximityPosition(0);

        if (!executePredicates(n, xctxt))
          return DTMIterator.FILTER_SKIP;
      }

      return DTMIterator.FILTER_ACCEPT;
    }
  }
  catch (javax.xml.transform.TransformerException se)
  {

    // TODO: Fix this.
    throw new RuntimeException(se.getMessage());
  }
  finally
  {
    xctxt.popCurrentNode();
  }

  return DTMIterator.FILTER_SKIP;
}
 
Example 7
Source File: ElemCopy.java    From j2objc with Apache License 2.0 4 votes vote down vote up
/**
 * The xsl:copy element provides an easy way of copying the current node.
 * Executing this function creates a copy of the current node into the
 * result tree.
 * <p>The namespace nodes of the current node are automatically
 * copied as well, but the attributes and children of the node are not
 * automatically copied. The content of the xsl:copy element is a
 * template for the attributes and children of the created node;
 * the content is instantiated only for nodes of types that can have
 * attributes or children (i.e. root nodes and element nodes).</p>
 * <p>The root node is treated specially because the root node of the
 * result tree is created implicitly. When the current node is the
 * root node, xsl:copy will not create a root node, but will just use
 * the content template.</p>
 *
 * @param transformer non-null reference to the the current transform-time state.
 *
 * @throws TransformerException
 */
public void execute(
        TransformerImpl transformer)
          throws TransformerException
{
              XPathContext xctxt = transformer.getXPathContext();
    
  try
  {
    int sourceNode = xctxt.getCurrentNode();
    xctxt.pushCurrentNode(sourceNode);
    DTM dtm = xctxt.getDTM(sourceNode);
    short nodeType = dtm.getNodeType(sourceNode);

    if ((DTM.DOCUMENT_NODE != nodeType) && (DTM.DOCUMENT_FRAGMENT_NODE != nodeType))
    {
      SerializationHandler rthandler = transformer.getSerializationHandler();

      // TODO: Process the use-attribute-sets stuff
      ClonerToResultTree.cloneToResultTree(sourceNode, nodeType, dtm, 
                                           rthandler, false);

      if (DTM.ELEMENT_NODE == nodeType)
      {
        super.execute(transformer);
        SerializerUtils.processNSDecls(rthandler, sourceNode, nodeType, dtm);
        transformer.executeChildTemplates(this, true);
        
        String ns = dtm.getNamespaceURI(sourceNode);
        String localName = dtm.getLocalName(sourceNode);
        transformer.getResultTreeHandler().endElement(ns, localName,
                                                      dtm.getNodeName(sourceNode));
      }
    }
    else
    {
      super.execute(transformer);
      transformer.executeChildTemplates(this, true);
    }
  }
  catch(org.xml.sax.SAXException se)
  {
    throw new TransformerException(se);
  }
  finally
  {
    xctxt.popCurrentNode();
  }
}
 
Example 8
Source File: ElemVariable.java    From j2objc with Apache License 2.0 4 votes vote down vote up
/**
 * Get the XObject representation of the variable.
 *
 * @param transformer non-null reference to the the current transform-time state.
 * @param sourceNode non-null reference to the <a href="http://www.w3.org/TR/xslt#dt-current-node">current source node</a>.
 *
 * @return the XObject representation of the variable.
 *
 * @throws TransformerException
 */
public XObject getValue(TransformerImpl transformer, int sourceNode)
        throws TransformerException
{

  XObject var;
  XPathContext xctxt = transformer.getXPathContext();

  xctxt.pushCurrentNode(sourceNode);
 
  try
  {
    if (null != m_selectPattern)
    {
      var = m_selectPattern.execute(xctxt, sourceNode, this);

      var.allowDetachToRelease(false);
    }
    else if (null == getFirstChildElem())
    {
      var = XString.EMPTYSTRING;
    }
    else
    {

      // Use result tree fragment.
      // Global variables may be deferred (see XUnresolvedVariable) and hence
      // need to be assigned to a different set of DTMs than local variables
      // so they aren't popped off the stack on return from a template.
      int df;

// Bugzilla 7118: A variable set via an RTF may create local
// variables during that computation. To keep them from overwriting
// variables at this level, push a new variable stack.
////// PROBLEM: This is provoking a variable-used-before-set
////// problem in parameters. Needs more study.
try
{
	//////////xctxt.getVarStack().link(0);
	if(m_parentNode instanceof Stylesheet) // Global variable
		df = transformer.transformToGlobalRTF(this);
	else
		df = transformer.transformToRTF(this);
  	}
finally{ 
	//////////////xctxt.getVarStack().unlink(); 
	}

      var = new XRTreeFrag(df, xctxt, this);
    }
  }
  finally
  {      
    xctxt.popCurrentNode();
  }

  return var;
}
 
Example 9
Source File: TreeWalker2Result.java    From j2objc with Apache License 2.0 4 votes vote down vote up
/**
 * Start traversal of the tree at the given node
 *
 *
 * @param node Starting node for traversal
 *
 * @throws TransformerException
 */
protected void startNode(int node) throws org.xml.sax.SAXException
{

  XPathContext xcntxt = m_transformer.getXPathContext();
  try
  {
    
    if (DTM.ELEMENT_NODE == m_dtm.getNodeType(node))
    {
      xcntxt.pushCurrentNode(node);                   
                                      
      if(m_startNode != node)
      {
        super.startNode(node);
      }
      else
      {
        String elemName = m_dtm.getNodeName(node);
        String localName = m_dtm.getLocalName(node);
        String namespace = m_dtm.getNamespaceURI(node);
                                      
        //xcntxt.pushCurrentNode(node);       
        // SAX-like call to allow adding attributes afterwards
        m_handler.startElement(namespace, localName, elemName);
        boolean hasNSDecls = false;
        DTM dtm = m_dtm;
        for (int ns = dtm.getFirstNamespaceNode(node, true); 
             DTM.NULL != ns; ns = dtm.getNextNamespaceNode(node, ns, true))
        {
          SerializerUtils.ensureNamespaceDeclDeclared(m_handler,dtm, ns);
        }
                                              
                                              
        for (int attr = dtm.getFirstAttribute(node); 
             DTM.NULL != attr; attr = dtm.getNextAttribute(attr))
        {
          SerializerUtils.addAttribute(m_handler, attr);
        }
      }
                              
    }
    else
    {
      xcntxt.pushCurrentNode(node);
      super.startNode(node);
      xcntxt.popCurrentNode();
    }
  }
  catch(javax.xml.transform.TransformerException te)
  {
    throw new org.xml.sax.SAXException(te);
  }
}
 
Example 10
Source File: StepPattern.java    From j2objc with Apache License 2.0 4 votes vote down vote up
/**
 * New Method to check whether the current node satisfies a position predicate
 *
 * @param xctxt The XPath runtime context.
 * @param predPos Which predicate we're evaluating of foo[1][2][3].
 * @param dtm The DTM of the current node.
 * @param context The currentNode.
 * @param pos The position being requested, i.e. the value returned by 
 *            m_predicates[predPos].execute(xctxt).
 *
 * @return true of the position of the context matches pos, false otherwise.
 */
private final boolean checkProximityPosition(XPathContext xctxt,
        int predPos, DTM dtm, int context, int pos)
{

  try
  {
    DTMAxisTraverser traverser =
      dtm.getAxisTraverser(Axis.PRECEDINGSIBLING);

    for (int child = traverser.first(context); DTM.NULL != child;
            child = traverser.next(context, child))
    {
      try
      {
        xctxt.pushCurrentNode(child);

        if (NodeTest.SCORE_NONE != super.execute(xctxt, child))
        {
          boolean pass = true;

          try
          {
            xctxt.pushSubContextList(this);

            for (int i = 0; i < predPos; i++)
            {
              xctxt.pushPredicatePos(i);
              try
              {
                XObject pred = m_predicates[i].execute(xctxt);
                
                try
                {
                  if (XObject.CLASS_NUMBER == pred.getType())
                  {
                    throw new Error("Why: Should never have been called");
                  }
                  else if (!pred.boolWithSideEffects())
                  {
                    pass = false;
  
                    break;
                  }
                }
                finally
                {
                  pred.detach();
                }
              }
              finally
              {
                xctxt.popPredicatePos();
              }
            }
          }
          finally
          {
            xctxt.popSubContextList();
          }

          if (pass)
            pos--;

          if (pos < 1)
            return false;
        }
      }
      finally
      {
        xctxt.popCurrentNode();
      }
    }
  }
  catch (javax.xml.transform.TransformerException se)
  {

    // TODO: should keep throw sax exception...
    throw new java.lang.RuntimeException(se.getMessage());
  }

  return (pos == 1);
}
 
Example 11
Source File: OneStepIterator.java    From j2objc with Apache License 2.0 4 votes vote down vote up
/**
 * Get the current sub-context position.  In order to do the
 * reverse axes count, for the moment this re-searches the axes
 * up to the predicate.  An optimization on this is to cache
 * the nodes searched, but, for the moment, this case is probably
 * rare enough that the added complexity isn't worth it.
 *
 * @param predicateIndex The predicate index of the proximity position.
 *
 * @return The pridicate index, or -1.
 */
protected int getProximityPosition(int predicateIndex)
{
  if(!isReverseAxes())
    return super.getProximityPosition(predicateIndex);
    
  // A negative predicate index seems to occur with
  // (preceding-sibling::*|following-sibling::*)/ancestor::*[position()]/*[position()]
  // -sb
  if(predicateIndex < 0)
    return -1;
    
  if (m_proximityPositions[predicateIndex] <= 0)
  {
    XPathContext xctxt = getXPathContext();
    try
    {
      OneStepIterator clone = (OneStepIterator) this.clone();
      
      int root = getRoot();
      xctxt.pushCurrentNode(root);
      clone.setRoot(root, xctxt);

      // clone.setPredicateCount(predicateIndex);
      clone.m_predCount = predicateIndex;

      // Count 'em all
      int count = 1;
      int next;

      while (DTM.NULL != (next = clone.nextNode()))
      {
        count++;
      }

      m_proximityPositions[predicateIndex] += count;
    }
    catch (CloneNotSupportedException cnse)
    {

      // can't happen
    }
    finally
    {
      xctxt.popCurrentNode();
    }
  }

  return m_proximityPositions[predicateIndex];
}
 
Example 12
Source File: OneStepIterator.java    From j2objc with Apache License 2.0 4 votes vote down vote up
/**
 *  The number of nodes in the list. The range of valid child node indices
 * is 0 to <code>length-1</code> inclusive.
 *
 * @return The number of nodes in the list, always greater or equal to zero.
 */
public int getLength()
{
  if(!isReverseAxes())
    return super.getLength();
    
  // Tell if this is being called from within a predicate.
  boolean isPredicateTest = (this == m_execContext.getSubContextList());

  // And get how many total predicates are part of this step.
  int predCount = getPredicateCount();
 
  // If we have already calculated the length, and the current predicate 
  // is the first predicate, then return the length.  We don't cache 
  // the anything but the length of the list to the first predicate.
  if (-1 != m_length && isPredicateTest && m_predicateIndex < 1)
     return m_length;      

  int count = 0;
  
  XPathContext xctxt = getXPathContext();
  try
  {
    OneStepIterator clone = (OneStepIterator) this.cloneWithReset();
    
    int root = getRoot();
    xctxt.pushCurrentNode(root);
    clone.setRoot(root, xctxt);
 
    clone.m_predCount = m_predicateIndex;

    int next;

    while (DTM.NULL != (next = clone.nextNode()))
    {
      count++;
    }
  }
  catch (CloneNotSupportedException cnse)
  {
     // can't happen
  }
  finally
  {
    xctxt.popCurrentNode();
  }
  if (isPredicateTest && m_predicateIndex < 1)
    m_length = count;    
    
  return count;
}
 
Example 13
Source File: MatchPatternIterator.java    From j2objc with Apache License 2.0 4 votes vote down vote up
/**
 *  Test whether a specified node is visible in the logical view of a
 * TreeWalker or NodeIterator. This function will be called by the
 * implementation of TreeWalker and NodeIterator; it is not intended to
 * be called directly from user code.
 * @param n  The node to check to see if it passes the filter or not.
 * @return  a constant to determine whether the node is accepted,
 *   rejected, or skipped, as defined  above .
 */
public short acceptNode(int n, XPathContext xctxt)
{

  try
  {
    xctxt.pushCurrentNode(n);
    xctxt.pushIteratorRoot(m_context);
    if(DEBUG)
    {
      System.out.println("traverser: "+m_traverser);
      System.out.print("node: "+n);
      System.out.println(", "+m_cdtm.getNodeName(n));
      // if(m_cdtm.getNodeName(n).equals("near-east"))
      System.out.println("pattern: "+m_pattern.toString());
      m_pattern.debugWhatToShow(m_pattern.getWhatToShow());
    }
    
    XObject score = m_pattern.execute(xctxt);
    
    if(DEBUG)
    {
      // System.out.println("analysis: "+Integer.toBinaryString(m_analysis));
      System.out.println("score: "+score);
      System.out.println("skip: "+(score == NodeTest.SCORE_NONE));
    }

    // System.out.println("\n::acceptNode - score: "+score.num()+"::");
    return (score == NodeTest.SCORE_NONE) ? DTMIterator.FILTER_SKIP 
                  : DTMIterator.FILTER_ACCEPT;
  }
  catch (javax.xml.transform.TransformerException se)
  {

    // TODO: Fix this.
    throw new RuntimeException(se.getMessage());
  }
  finally
  {
    xctxt.popCurrentNode();
    xctxt.popIteratorRoot();
  }

}
 
Example 14
Source File: FilterExprIteratorSimple.java    From j2objc with Apache License 2.0 4 votes vote down vote up
/**
 * Execute the expression.  Meant for reuse by other FilterExpr iterators 
 * that are not derived from this object.
 */
public static XNodeSet executeFilterExpr(int context, XPathContext xctxt, 
												PrefixResolver prefixResolver,
												boolean isTopLevel,
												int stackFrame,
												Expression expr )
  throws org.apache.xml.utils.WrappedRuntimeException
{
  PrefixResolver savedResolver = xctxt.getNamespaceContext();
  XNodeSet result = null;

  try
  {
    xctxt.pushCurrentNode(context);
    xctxt.setNamespaceContext(prefixResolver);

    // The setRoot operation can take place with a reset operation, 
    // and so we may not be in the context of LocPathIterator#nextNode, 
    // so we have to set up the variable context, execute the expression, 
    // and then restore the variable context.

    if (isTopLevel)
    {
      // System.out.println("calling m_expr.execute(getXPathContext())");
      VariableStack vars = xctxt.getVarStack();

      // These three statements need to be combined into one operation.
      int savedStart = vars.getStackFrame();
      vars.setStackFrame(stackFrame);

      result = (org.apache.xpath.objects.XNodeSet) expr.execute(xctxt);
      result.setShouldCacheNodes(true);

      // These two statements need to be combined into one operation.
      vars.setStackFrame(savedStart);
    }
    else
        result = (org.apache.xpath.objects.XNodeSet) expr.execute(xctxt);

  }
  catch (javax.xml.transform.TransformerException se)
  {

    // TODO: Fix...
    throw new org.apache.xml.utils.WrappedRuntimeException(se);
  }
  finally
  {
    xctxt.popCurrentNode();
    xctxt.setNamespaceContext(savedResolver);
  }
  return result;
}
 
Example 15
Source File: PredicatedNodeTest.java    From j2objc with Apache License 2.0 4 votes vote down vote up
/**
 * Process the predicates.
 *
 * @param context The current context node.
 * @param xctxt The XPath runtime context.
 *
 * @return the result of executing the predicate expressions.
 *
 * @throws javax.xml.transform.TransformerException
 */
boolean executePredicates(int context, XPathContext xctxt)
        throws javax.xml.transform.TransformerException
{
  
  int nPredicates = getPredicateCount();
  // System.out.println("nPredicates: "+nPredicates);
  if (nPredicates == 0)
    return true;

  PrefixResolver savedResolver = xctxt.getNamespaceContext();

  try
  {
    m_predicateIndex = 0;
    xctxt.pushSubContextList(this);
    xctxt.pushNamespaceContext(m_lpi.getPrefixResolver());
    xctxt.pushCurrentNode(context);

    for (int i = 0; i < nPredicates; i++)
    {
      // System.out.println("Executing predicate expression - waiting count: "+m_lpi.getWaitingCount());
      XObject pred = m_predicates[i].execute(xctxt);
      // System.out.println("\nBack from executing predicate expression - waiting count: "+m_lpi.getWaitingCount());
      // System.out.println("pred.getType(): "+pred.getType());
      if (XObject.CLASS_NUMBER == pred.getType())
      {
        if (DEBUG_PREDICATECOUNTING)
        {
          System.out.flush();
          System.out.println("\n===== start predicate count ========");
          System.out.println("m_predicateIndex: " + m_predicateIndex);
          // System.out.println("getProximityPosition(m_predicateIndex): "
          //                   + getProximityPosition(m_predicateIndex));
          System.out.println("pred.num(): " + pred.num());
        }

        int proxPos = this.getProximityPosition(m_predicateIndex);
        int predIndex = (int) pred.num();
        if (proxPos != predIndex)
        {
          if (DEBUG_PREDICATECOUNTING)
          {
            System.out.println("\nnode context: "+nodeToString(context));
            System.out.println("index predicate is false: "+proxPos);
            System.out.println("\n===== end predicate count ========");
          }
          return false;
        }
        else if (DEBUG_PREDICATECOUNTING)
        {
          System.out.println("\nnode context: "+nodeToString(context));
          System.out.println("index predicate is true: "+proxPos);
          System.out.println("\n===== end predicate count ========");
        }
        
        // If there is a proximity index that will not change during the 
        // course of itteration, then we know there can be no more true 
        // occurances of this predicate, so flag that we're done after 
        // this.
        //
        // bugzilla 14365
        // We can't set m_foundLast = true unless we're sure that -all-
        // remaining parameters are stable, or else last() fails. Fixed so
        // only sets m_foundLast if on the last predicate
        if(m_predicates[i].isStableNumber() && i == nPredicates - 1)
        {
          m_foundLast = true;
        }
      }
      else if (!pred.bool())
        return false;

      countProximityPosition(++m_predicateIndex);
    }
  }
  finally
  {
    xctxt.popCurrentNode();
    xctxt.popNamespaceContext();
    xctxt.popSubContextList();
    m_predicateIndex = -1;
  }

  return true;
}