You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@apache.org on 2001/08/07 21:16:43 UTC

cvs commit: xml-xalan/java/src/org/apache/xpath/objects XObjectFactory.java

sboag       01/08/07 12:16:43

  Modified:    java/src/org/apache/xalan/extensions
                        XSLProcessorContext.java
               java/src/org/apache/xml/dtm DTMIterator.java
               java/src/org/apache/xml/dtm/ref DTMAxisIteratorBase.java
               java/src/org/apache/xpath NodeSetDTM.java
               java/src/org/apache/xpath/axes AttributeIterator.java
                        AxesWalker.java ChildIterator.java
                        ChildTestIterator.java DescendantIterator.java
                        FilterExprWalker.java LocPathIterator.java
                        OneStepIterator.java OneStepIteratorForward.java
                        ReverseAxesWalker.java UnionPathIterator.java
                        WalkingIteratorSorted.java
               java/src/org/apache/xpath/objects XObjectFactory.java
  Log:
  Changes to allow some dynamic determination in WalkerIteratorSorted to
  see if the nodes really need to be sorted.  Added isDocOrdered() and
  getAxis() to both DTMIterator and AxesWalker, and implemented
  appropriate overloads in derived or implementing classes.  In FilterExprWalker
  return the contained DTMIterator's getAxis().  In WalkerIteratorSorted,
  implement canBeWalkedInNaturalDocOrder() function that is called
  from setRoot(...).  If this function returns true, than don't sort the nodes
  in setRoot, and in all other respects treat this as if it is a simple
  WalkingIterator.
  
  Revision  Changes    Path
  1.12      +1 -1      xml-xalan/java/src/org/apache/xalan/extensions/XSLProcessorContext.java
  
  Index: XSLProcessorContext.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/extensions/XSLProcessorContext.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- XSLProcessorContext.java	2001/07/13 19:13:31	1.11
  +++ XSLProcessorContext.java	2001/08/07 19:16:42	1.12
  @@ -241,7 +241,7 @@
         else if (obj instanceof DTMAxisIterator)
         {
           DTMAxisIterator iter = (DTMAxisIterator)obj;
  -        DTMIterator iterator = new OneStepIterator(iter);
  +        DTMIterator iterator = new OneStepIterator(iter, -1);
           value = new XNodeSet(iterator);
         }
         else if (obj instanceof DTMIterator)
  
  
  
  1.4       +17 -0     xml-xalan/java/src/org/apache/xml/dtm/DTMIterator.java
  
  Index: DTMIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/DTMIterator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DTMIterator.java	2001/06/15 05:15:03	1.3
  +++ DTMIterator.java	2001/08/07 19:16:42	1.4
  @@ -359,5 +359,22 @@
      * @throws CloneNotSupportedException
      */
     public Object clone() throws CloneNotSupportedException;
  +  
  +  /**
  +   * Returns true if all the nodes in the iteration well be returned in document 
  +   * order.
  +   * 
  +   * @return true if all the nodes in the iteration well be returned in document 
  +   * order.
  +   */
  +  public boolean isDocOrdered();
  +  
  +  /**
  +   * Returns the axis being iterated, if it is known.
  +   * 
  +   * @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple 
  +   * types.
  +   */
  +  public int getAxis();
   
   }
  
  
  
  1.5       +23 -0     xml-xalan/java/src/org/apache/xml/dtm/ref/DTMAxisIteratorBase.java
  
  Index: DTMAxisIteratorBase.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMAxisIteratorBase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DTMAxisIteratorBase.java	2001/08/04 20:54:20	1.4
  +++ DTMAxisIteratorBase.java	2001/08/07 19:16:42	1.5
  @@ -265,4 +265,27 @@
   
       return this;
     }
  +  
  +  /**
  +   * Returns true if all the nodes in the iteration well be returned in document 
  +   * order.
  +   * 
  +   * @return true as a default.
  +   */
  +  public boolean isDocOrdered()
  +  {
  +    return true;
  +  }
  +  
  +  /**
  +   * Returns the axis being iterated, if it is known.
  +   * 
  +   * @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple 
  +   * types.
  +   */
  +  public int getAxis()
  +  {
  +    return -1;
  +  }
  +
   }
  
  
  
  1.6       +21 -0     xml-xalan/java/src/org/apache/xpath/NodeSetDTM.java
  
  Index: NodeSetDTM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/NodeSetDTM.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- NodeSetDTM.java	2001/08/04 18:23:30	1.5
  +++ NodeSetDTM.java	2001/08/07 19:16:42	1.6
  @@ -1252,6 +1252,27 @@
       m_last = last;
     }
     
  +  /**
  +   * Returns true if all the nodes in the iteration well be returned in document 
  +   * order.
  +   * 
  +   * @return true as a default.
  +   */
  +  public boolean isDocOrdered()
  +  {
  +    return true;
  +  }
  +  
  +  /**
  +   * Returns the axis being iterated, if it is known.
  +   * 
  +   * @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple 
  +   * types.
  +   */
  +  public int getAxis()
  +  {
  +    return -1;
  +  }
     
   
   }
  
  
  
  1.9       +13 -0     xml-xalan/java/src/org/apache/xpath/axes/AttributeIterator.java
  
  Index: AttributeIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/AttributeIterator.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AttributeIterator.java	2001/06/12 19:16:13	1.8
  +++ AttributeIterator.java	2001/08/07 19:16:43	1.9
  @@ -101,5 +101,18 @@
                        : m_cdtm.getNextAttribute(m_lastFetched);
       return m_lastFetched;
     }
  +  
  +  /**
  +   * Returns the axis being iterated, if it is known.
  +   * 
  +   * @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple 
  +   * types.
  +   */
  +  public int getAxis()
  +  {
  +    return org.apache.xml.dtm.Axis.ATTRIBUTE;
  +  }
  +
  +
   
   }
  
  
  
  1.21      +24 -0     xml-xalan/java/src/org/apache/xpath/axes/AxesWalker.java
  
  Index: AxesWalker.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/AxesWalker.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- AxesWalker.java	2001/07/28 00:45:05	1.20
  +++ AxesWalker.java	2001/08/07 19:16:43	1.21
  @@ -518,6 +518,30 @@
       //
       return wi().getXPathContext().getDTM(node);
     }
  +  
  +  /**
  +   * Returns true if all the nodes in the iteration well be returned in document 
  +   * order.
  +   * Warning: This can only be called after setRoot has been called!
  +   * 
  +   * @return true as a default.
  +   */
  +  public boolean isDocOrdered()
  +  {
  +    return true;
  +  }
  +  
  +  /**
  +   * Returns the axis being iterated, if it is known.
  +   * 
  +   * @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple 
  +   * types.
  +   */
  +  public int getAxis()
  +  {
  +    return m_axis;
  +  }
  +
   
     /**
      *  The root node of the TreeWalker, as specified when it was created.
  
  
  
  1.8       +13 -0     xml-xalan/java/src/org/apache/xpath/axes/ChildIterator.java
  
  Index: ChildIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/ChildIterator.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ChildIterator.java	2001/06/12 19:16:15	1.7
  +++ ChildIterator.java	2001/08/07 19:16:43	1.8
  @@ -164,4 +164,17 @@
         return DTM.NULL;
       }
     }
  +  
  +  /**
  +   * Returns the axis being iterated, if it is known.
  +   * 
  +   * @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple 
  +   * types.
  +   */
  +  public int getAxis()
  +  {
  +    return org.apache.xml.dtm.Axis.CHILD;
  +  }
  +
  +
   }
  
  
  
  1.12      +12 -0     xml-xalan/java/src/org/apache/xpath/axes/ChildTestIterator.java
  
  Index: ChildTestIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/ChildTestIterator.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ChildTestIterator.java	2001/07/31 22:23:38	1.11
  +++ ChildTestIterator.java	2001/08/07 19:16:43	1.12
  @@ -304,5 +304,17 @@
   //    }
       
     }
  +  
  +  /**
  +   * Returns the axis being iterated, if it is known.
  +   * 
  +   * @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple 
  +   * types.
  +   */
  +  public int getAxis()
  +  {
  +    return org.apache.xml.dtm.Axis.CHILD;
  +  }
  +
   
   }
  
  
  
  1.13      +11 -0     xml-xalan/java/src/org/apache/xpath/axes/DescendantIterator.java
  
  Index: DescendantIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/DescendantIterator.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DescendantIterator.java	2001/07/30 20:09:22	1.12
  +++ DescendantIterator.java	2001/08/07 19:16:43	1.13
  @@ -399,6 +399,17 @@
       // Always call the superclass detach last!
       super.detach();
     }
  +  
  +  /**
  +   * Returns the axis being iterated, if it is known.
  +   * 
  +   * @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple 
  +   * types.
  +   */
  +  public int getAxis()
  +  {
  +    return m_axis;
  +  }
   
     
     /** The traverser to use to navigate over the descendants. */
  
  
  
  1.19      +25 -0     xml-xalan/java/src/org/apache/xpath/axes/FilterExprWalker.java
  
  Index: FilterExprWalker.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/FilterExprWalker.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- FilterExprWalker.java	2001/06/23 03:54:30	1.18
  +++ FilterExprWalker.java	2001/08/07 19:16:43	1.19
  @@ -277,5 +277,30 @@
       super.fixupVariables(vars, globalsSize);
       m_expr.fixupVariables(vars, globalsSize);
     }
  +  
  +  /**
  +   * Returns true if all the nodes in the iteration well be returned in document 
  +   * order.
  +   * Warning: This can only be called after setRoot has been called!
  +   * 
  +   * @return true as a default.
  +   */
  +  public boolean isDocOrdered()
  +  {
  +    return m_nodeSet.isDocOrdered();
  +  }
  +  
  +  /**
  +   * Returns the axis being iterated, if it is known.
  +   * 
  +   * @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple 
  +   * types.
  +   */
  +  public int getAxis()
  +  {
  +    return m_nodeSet.getAxis();
  +  }
  +
  +
   
   }
  
  
  
  1.32      +23 -0     xml-xalan/java/src/org/apache/xpath/axes/LocPathIterator.java
  
  Index: LocPathIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/LocPathIterator.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- LocPathIterator.java	2001/07/28 00:45:05	1.31
  +++ LocPathIterator.java	2001/08/07 19:16:43	1.32
  @@ -1050,6 +1050,29 @@
      * NodeList.
      */
     transient protected int m_next;
  +  
  +  /**
  +   * Returns true if all the nodes in the iteration well be returned in document 
  +   * order.
  +   * 
  +   * @return true as a default.
  +   */
  +  public boolean isDocOrdered()
  +  {
  +    return true;
  +  }
  +  
  +  /**
  +   * Returns the axis being iterated, if it is known.
  +   * 
  +   * @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple 
  +   * types.
  +   */
  +  public int getAxis()
  +  {
  +    return -1;
  +  }
  +
   
   //  /**
   //   * The analysis pattern built by the WalkerFactory.
  
  
  
  1.6       +16 -4     xml-xalan/java/src/org/apache/xpath/axes/OneStepIterator.java
  
  Index: OneStepIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/OneStepIterator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- OneStepIterator.java	2001/08/06 00:28:59	1.5
  +++ OneStepIterator.java	2001/08/07 19:16:43	1.6
  @@ -49,18 +49,18 @@
     /**
      * Create a OneStepIterator object.
      *
  -   * @param compiler A reference to the Compiler that contains the op map.
  -   * @param opPos The position within the op map, which contains the
  -   * location path expression for this itterator.
  +   * @param iterator The DTM iterator which this iterator will use.
  +   * @param axis One of Axis.Child, etc., or -1 if the axis is unknown.
      *
      * @throws javax.xml.transform.TransformerException
      */
  -  public OneStepIterator(DTMAxisIterator iterator)
  +  public OneStepIterator(DTMAxisIterator iterator, int axis)
             throws javax.xml.transform.TransformerException
     {
       super(null);
       
       m_iterator = iterator;
  +    m_axis = axis;
       int whatToShow = DTMFilter.SHOW_ALL;
       initNodeTest(whatToShow);
     }
  @@ -252,5 +252,17 @@
       if(null != m_iterator)
         m_iterator.reset();
     }
  +  
  +  /**
  +   * Returns the axis being iterated, if it is known.
  +   * 
  +   * @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple 
  +   * types.
  +   */
  +  public int getAxis()
  +  {
  +    return m_axis;
  +  }
  +
   
   }
  
  
  
  1.4       +12 -0     xml-xalan/java/src/org/apache/xpath/axes/OneStepIteratorForward.java
  
  Index: OneStepIteratorForward.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/OneStepIteratorForward.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- OneStepIteratorForward.java	2001/07/31 22:23:38	1.3
  +++ OneStepIteratorForward.java	2001/08/07 19:16:43	1.4
  @@ -129,4 +129,16 @@
       return m_lastFetched;
     }
     
  +  /**
  +   * Returns the axis being iterated, if it is known.
  +   * 
  +   * @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple 
  +   * types.
  +   */
  +  public int getAxis()
  +  {
  +    return m_axis;
  +  }
  +
  +  
   }
  
  
  
  1.9       +12 -0     xml-xalan/java/src/org/apache/xpath/axes/ReverseAxesWalker.java
  
  Index: ReverseAxesWalker.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/ReverseAxesWalker.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ReverseAxesWalker.java	2001/07/28 00:45:05	1.8
  +++ ReverseAxesWalker.java	2001/08/07 19:16:43	1.9
  @@ -263,6 +263,18 @@
       return count;
     }
     
  +  /**
  +   * Returns true if all the nodes in the iteration well be returned in document 
  +   * order.
  +   * Warning: This can only be called after setRoot has been called!
  +   * 
  +   * @return false.
  +   */
  +  public boolean isDocOrdered()
  +  {
  +    return false;  // I think.
  +  }
  +  
     /** The DTM inner traversal class, that corresponds to the super axis. */
     protected DTMAxisIterator m_iterator;
   }
  
  
  
  1.23      +24 -0     xml-xalan/java/src/org/apache/xpath/axes/UnionPathIterator.java
  
  Index: UnionPathIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/UnionPathIterator.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- UnionPathIterator.java	2001/07/17 18:17:54	1.22
  +++ UnionPathIterator.java	2001/08/07 19:16:43	1.23
  @@ -994,4 +994,28 @@
     {
       m_last = last;
     }
  +  
  +  /**
  +   * Returns true if all the nodes in the iteration well be returned in document 
  +   * order.
  +   * 
  +   * @return true as a default.
  +   */
  +  public boolean isDocOrdered()
  +  {
  +    return true;
  +  }
  +  
  +  /**
  +   * Returns the axis being iterated, if it is known.
  +   * 
  +   * @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple 
  +   * types.
  +   */
  +  public int getAxis()
  +  {
  +    // Could be smarter.
  +    return -1;
  +  }
  +
   }
  
  
  
  1.5       +219 -92   xml-xalan/java/src/org/apache/xpath/axes/WalkingIteratorSorted.java
  
  Index: WalkingIteratorSorted.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/WalkingIteratorSorted.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WalkingIteratorSorted.java	2001/07/17 18:17:55	1.4
  +++ WalkingIteratorSorted.java	2001/08/07 19:16:43	1.5
  @@ -1,3 +1,59 @@
  +/*
  + * The Apache Software License, Version 1.1
  + *
  + *
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer. 
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + *    if any, must include the following acknowledgment:  
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowledgment may appear in the software itself,
  + *    if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "Xalan" and "Apache Software Foundation" must
  + *    not be used to endorse or promote products derived from this
  + *    software without prior written permission. For written 
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + *    nor may "Apache" appear in their name, without prior written
  + *    permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation and was
  + * originally based on software copyright (c) 1999, Lotus
  + * Development Corporation., http://www.lotus.com.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
   package org.apache.xpath.axes;
   
   import org.apache.xpath.XPathContext;
  @@ -5,9 +61,18 @@
   import org.apache.xpath.compiler.Compiler;
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.DTMIterator;
  +import org.apache.xml.dtm.Axis;
   
  +/**
  + * <meta name="usage" content="internal"/>
  + * NEEDSDOC Class WalkingIteratorSorted <needs-comment/>
  + */
   public class WalkingIteratorSorted extends WalkingIterator
   {
  +
  +  /** NEEDSDOC Field m_inNaturalOrder          */
  +  protected boolean m_inNaturalOrder = false;
  +
     /**
      * Create a WalkingIteratorSorted object.
      *
  @@ -16,7 +81,6 @@
      */
     public WalkingIteratorSorted(PrefixResolver nscontext)
     {
  -
       super(nscontext);
     }
   
  @@ -27,6 +91,7 @@
      * this expression.
      * @param opPos The position of this iterator in the
      * opcode list from the compiler.
  +   * NEEDSDOC @param analysis
      * @param shouldLoadWalkers True if walkers should be
      * loaded, or false if this is a derived iterator and
      * it doesn't wish to load child walkers.
  @@ -37,133 +102,195 @@
             Compiler compiler, int opPos, int analysis, boolean shouldLoadWalkers)
               throws javax.xml.transform.TransformerException
     {
  +
       super(compiler, opPos, analysis, shouldLoadWalkers);
  +
       //this.setShouldCacheNodes(true);
     }
  -  
  +
     /**
  +   * NEEDSDOC Method canBeWalkedInNaturalDocOrder 
  +   *
  +   *
  +   * NEEDSDOC (canBeWalkedInNaturalDocOrder) @return
  +   */
  +  boolean canBeWalkedInNaturalDocOrder()
  +  {
  +
  +    if (null != m_firstWalker)
  +    {
  +      AxesWalker walker = m_firstWalker;
  +      int prevAxis = -1;
  +      boolean prevIsSimpleDownAxis = true;
  +
  +      for(int i = 0; null != walker; i++)
  +      {
  +        int axis = walker.getAxis();
  +        boolean isSimpleDownAxis = ((axis == Axis.CHILD)
  +           || (axis == Axis.ATTRIBUTE) || (axis == Axis.SELF)
  +           || (axis == Axis.ROOT));
  +        if(walker.isDocOrdered())
  +        {
  +          if(isSimpleDownAxis)
  +            walker = walker.getNextWalker();
  +          else
  +          {
  +            boolean nextIsNull = (null == walker.getNextWalker());
  +            if(nextIsNull)
  +            {
  +              if(walker.isDocOrdered() && (axis == Axis.DESCENDANT || 
  +                 axis == Axis.DESCENDANTORSELF || axis == Axis.DESCENDANTSFROMROOT
  +                 || axis == Axis.DESCENDANTSORSELFFROMROOT))
  +                return true;
  +            }
  +            return false;
  +          }
  +        }
  +        else
  +          return false;
  +      }
  +      return true;
  +    }
  +    return false;
  +  }
  +
  +  /**
      * Initialize the context values for this expression
      * after it is cloned.
      *
      * @param execContext The XPath runtime context for this
      * transformation.
  +   *
  +   * NEEDSDOC @param context
  +   * NEEDSDOC @param environment
      */
     public void setRoot(int context, Object environment)
     {
  +
       super.setRoot(context, environment);
  -    
  -    this.setShouldCacheNodes(true);
  -    
  -    // This should really be done in the super's setRoot, but if I do that 
  -    // it becomes unhappy in the minitest... possibly something to do with 
  -    // the keyref iterator.  -sb
  -    m_cachedNodes.setLast(0);
  -    m_cachedNodes.reset();
  -    m_cachedNodes.RemoveAllNoClear();
  -
  -    setNextPosition(0);
  -    m_firstWalker.setRoot(context);
  -
  -    m_lastUsedWalker = m_firstWalker;
  -
  -    int nextNode = DTM.NULL;
  -    AxesWalker walker = getLastUsedWalker();
  -    XPathContext execContext = (XPathContext)environment;
  -    execContext.pushCurrentNodeAndExpression(context, context);
  -    
  -    try
  -    {
   
  -    do
  +    m_inNaturalOrder = canBeWalkedInNaturalDocOrder();
  +
  +    if (!m_inNaturalOrder)
       {
  -      while (true)
  -      {
  -        if (null == walker)
  -          break;
  +      this.setShouldCacheNodes(true);
   
  -        nextNode = walker.getNextNode();
  +      // This should really be done in the super's setRoot, but if I do that 
  +      // it becomes unhappy in the minitest... possibly something to do with 
  +      // the keyref iterator.  -sb
  +      m_cachedNodes.setLast(0);
  +      m_cachedNodes.reset();
  +      m_cachedNodes.RemoveAllNoClear();
  +      setNextPosition(0);
  +      m_firstWalker.setRoot(context);
   
  -        if (DTM.NULL == nextNode)
  -        {
  -          walker = walker.m_prevWalker;
  -        }
  -        else
  -        {
  -          if (walker.acceptNode(nextNode) != DTMIterator.FILTER_ACCEPT)
  -          {
  -            continue;
  -          }
  +      m_lastUsedWalker = m_firstWalker;
   
  -          if (null == walker.m_nextWalker)
  -          {
  -            setLastUsedWalker(walker);
  +      int nextNode = DTM.NULL;
  +      AxesWalker walker = getLastUsedWalker();
  +      XPathContext execContext = (XPathContext) environment;
   
  -            // return walker.returnNextNode(nextNode);
  -            break;
  -          }
  -          else
  +      execContext.pushCurrentNodeAndExpression(context, context);
  +
  +      try
  +      {
  +        do
  +        {
  +          while (true)
             {
  -            AxesWalker prev = walker;
  +            if (null == walker)
  +              break;
  +
  +            nextNode = walker.getNextNode();
   
  -            walker = walker.m_nextWalker;
  +            if (DTM.NULL == nextNode)
  +            {
  +              walker = walker.m_prevWalker;
  +            }
  +            else
  +            {
  +              if (walker.acceptNode(nextNode) != DTMIterator.FILTER_ACCEPT)
  +              {
  +                continue;
  +              }
  +
  +              if (null == walker.m_nextWalker)
  +              {
  +                setLastUsedWalker(walker);
  +
  +                // return walker.returnNextNode(nextNode);
  +                break;
  +              }
  +              else
  +              {
  +                AxesWalker prev = walker;
  +
  +                walker = walker.m_nextWalker;
  +
  +                walker.setRoot(nextNode);
  +
  +                walker.m_prevWalker = prev;
  +
  +                continue;
  +              }
  +            }  // if(null != nextNode)
  +          }  // while(null != walker)
   
  -            walker.setRoot(nextNode);
  +          if (DTM.NULL != nextNode)
  +          {
  +            incrementNextPosition();
   
  -            walker.m_prevWalker = prev;
  +            // m_currentContextNode = nextNode;
  +            m_cachedNodes.addNodeInDocOrder(nextNode, execContext);
   
  -            continue;
  +            walker = getLastUsedWalker();
             }
  -        }  // if(null != nextNode)
  -      }  // while(null != walker)
  -      
  -      if(DTM.NULL != nextNode)
  +        }
  +        while (DTM.NULL != nextNode);
  +      }
  +      finally
         {
  -        incrementNextPosition();
  -        // m_currentContextNode = nextNode;
  -        m_cachedNodes.addNodeInDocOrder(nextNode, execContext);
  -        walker = getLastUsedWalker();
  +        execContext.popCurrentNodeAndExpression();
         }
  -    }
  -      while (DTM.NULL != nextNode);
  -      
  -    }
  -    finally
  -    {
  -      execContext.popCurrentNodeAndExpression();
  -    }
   
  -    // m_prevReturned = nextNode;
  -    setNextPosition(0);
  -    m_last = m_cachedNodes.size();
  -    m_lastFetched = DTM.NULL;
  -    m_currentContextNode = DTM.NULL;
  -    m_foundLast = true;
  -  }
  -  
  -  public int nextNode()
  -  {
  -    return super.nextNode();
  +      // m_prevReturned = nextNode;
  +      setNextPosition(0);
  +
  +      m_last = m_cachedNodes.size();
  +      m_lastFetched = DTM.NULL;
  +      m_currentContextNode = DTM.NULL;
  +      m_foundLast = true;
  +    }
     }
  -  
  +
  +  //  public int nextNode()
  +  //  {
  +  //    return super.nextNode();
  +  //  }
  +
     /**
      * Reset the iterator.
      */
     public void reset()
     {
   
  -    // super.reset();
  -    // m_foundLast = false;
  -    m_lastFetched = DTM.NULL;
  -    m_next = 0;
  -    // m_last = 0;
  -    
  -    if (null != m_firstWalker)
  +    if (m_inNaturalOrder)
  +      super.reset();
  +    else
       {
  -      m_lastUsedWalker = m_firstWalker;
   
  -      m_firstWalker.setRoot(m_context);
  -    }
  +      // super.reset();
  +      // m_foundLast = false;
  +      m_lastFetched = DTM.NULL;
  +      m_next = 0;
   
  +      // m_last = 0;
  +      if (null != m_firstWalker)
  +      {
  +        m_lastUsedWalker = m_firstWalker;
  +
  +        m_firstWalker.setRoot(m_context);
  +      }
  +    }
     }
  -  
  -}
  \ No newline at end of file
  +}
  
  
  
  1.2       +2 -2      xml-xalan/java/src/org/apache/xpath/objects/XObjectFactory.java
  
  Index: XObjectFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XObjectFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XObjectFactory.java	2001/08/06 04:54:41	1.1
  +++ XObjectFactory.java	2001/08/07 19:16:43	1.2
  @@ -86,7 +86,7 @@
           int dtmRoot = dtm.getDocument();
           DTMAxisIterator iter = dtm.getAxisIterator(Axis.SELF);
           iter.setStartNode(dtmRoot);
  -        DTMIterator iterator = new OneStepIterator(iter);
  +        DTMIterator iterator = new OneStepIterator(iter, Axis.SELF);
           iterator.setRoot(dtmRoot, xctxt);
           result = new XNodeSet(iterator);
         }
  @@ -100,7 +100,7 @@
         DTMAxisIterator iter = (DTMAxisIterator)val;
         try
         {
  -        DTMIterator iterator = new OneStepIterator(iter);
  +        DTMIterator iterator = new OneStepIterator(iter, Axis.SELF);
           iterator.setRoot(iter.getStartNode(), xctxt);
           result = new XNodeSet(iterator);
         }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org