jkesselm    00/12/15 13:17:29

  Modified:    java/src/org/apache/xpath DOMHelper.java
  Log:
  Some doc fixes, some open questions
  
  Revision  Changes    Path
  1.19      +20 -6     xml-xalan/java/src/org/apache/xpath/DOMHelper.java
  
  Index: DOMHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/DOMHelper.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- DOMHelper.java    2000/12/15 20:00:44     1.18
  +++ DOMHelper.java    2000/12/15 21:17:28     1.19
  @@ -332,12 +332,17 @@
   
     /**
      * Figure out if child2 is after child1 in document order.
  +   * <p>
  +   * Warning: Some aspects of "document order" are not well defined.
  +   * For example, the order of attributes is considered
  +   * meaningless in XML, and the order reported by our model will
  +   * be consistant for a given invocation but may not 
  +   * match that of either the source file or the serialized output.
  +   * 
      * @param parent Must be the parent of both child1 and child2.
      * @param child1 Must be the child of parent and not equal to child2.
      * @param child2 Must be the child of parent and not equal to child1.
  -   * @returns true if child 2 is after child1 in document order.
  -   *
  -   * NEEDSDOC ($objectName$) @return
  +   * @return true if child 2 is after child1 in document order.
      */
     private static boolean isNodeAfterSibling(Node parent, Node child1,
                                               Node child2)
  @@ -367,6 +372,7 @@
         int nNodes = children.getLength();
         boolean found1 = false, found2 = false;
   
  +       // Count from the start until we find one or the other.
         for (int i = 0; i < nNodes; i++)
         {
           Node child = children.item(i);
  @@ -397,9 +403,17 @@
       }
       else
       {
  -
  -      // NodeList children = parent.getChildNodes();
  -      // int nNodes = children.getLength();
  +             // TODO: Check performance of alternate solution:
  +             // There are two choices here: Count from the start of
  +             // the document until we find one or the other, or count
  +             // from one until we find or fail to find the other.
  +             // Either can wind up scanning all the siblings in the worst
  +             // case, which on a wide document can be a lot of work but
  +             // is more typically is a short list. 
  +             // Scanning from the start involves two tests per iteration,
  +             // but it isn't clear that scanning from the middle doesn't
  +             // yield more iterations on average. 
  +             // We should run some testcases.
         Node child = parent.getFirstChild();
         boolean found1 = false, found2 = false;
   
  
  
  

Reply via email to