sboag       99/12/14 14:25:11

  Modified:    src/org/apache/xalan/xpath MutableNodeListImpl.java
                        XRTreeFrag.java
               src/org/apache/xalan/xpath/dtm DTM.java DTMLiaison.java
               src/org/apache/xalan/xslt ElemTemplateElement.java
                        FuncDocument.java
  Log:
  Fixed sorting with multiple nodes from multiple docs when using the DTM.
  
  Revision  Changes    Path
  1.5       +11 -2     
xml-xalan/src/org/apache/xalan/xpath/MutableNodeListImpl.java
  
  Index: MutableNodeListImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/src/org/apache/xalan/xpath/MutableNodeListImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MutableNodeListImpl.java  1999/12/13 08:06:01     1.4
  +++ MutableNodeListImpl.java  1999/12/14 22:25:09     1.5
  @@ -268,6 +268,7 @@
      }
       return foundit;
     }
  +  
   
     /**
      * Add the node into a vector of nodes where it should occur in 
  @@ -290,8 +291,16 @@
           int size = size(), i;
           for(i = size-1; i >= 0; i--)
           {
  -          int index2 = 
((org.apache.xalan.xpath.dtm.DTMProxy)elementAt(i)).getDTMNodeNumber();
  -          if(index2 == index1)
  +          Node node2 = (Node)elementAt(i);
  +          // Check to see if the nodes share the same parent.  If they 
  +          // do not, then don't try to sort with it.
  +          if(!((((1 == index1) && (node == node2)) ||
  +             (node.getOwnerDocument() == node2.getOwnerDocument()))))
  +          {
  +            continue;
  +          }
  +          int index2 = 
((org.apache.xalan.xpath.dtm.DTMProxy)node2).getDTMNodeNumber();
  +          if((index2 == index1))
             {
               i = -2; // Duplicate, suppress insert
               break; 
  
  
  
  1.6       +2 -2      xml-xalan/src/org/apache/xalan/xpath/XRTreeFrag.java
  
  Index: XRTreeFrag.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/XRTreeFrag.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XRTreeFrag.java   1999/12/13 18:23:34     1.5
  +++ XRTreeFrag.java   1999/12/14 22:25:09     1.6
  @@ -162,9 +162,9 @@
     }
     
     /**
  -   * Cast result object to a nodelist.
  +   * Cast result object to a nodelist. (special function).
      */
  -  public NodeList nodeset()
  +  public NodeList convertToNodeset()
     {
       return ((DocumentFragment)m_obj).getChildNodes();
     }  
  
  
  
  1.6       +14 -10    xml-xalan/src/org/apache/xalan/xpath/dtm/DTM.java
  
  Index: DTM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/dtm/DTM.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DTM.java  1999/12/13 07:46:58     1.5
  +++ DTM.java  1999/12/14 22:25:09     1.6
  @@ -529,17 +529,21 @@
   
       StringToStringTable pushNS = m_emptyNamespace;
       // Process any new namespace declarations
  -    for (int i = 0; i < atts.getLength(); i++)
  +    int nAttrs = atts.getLength();
  +    for (int i = 0; i < nAttrs; i++)
       {
         String attrname = atts.getName(i);
  -      boolean isPrefix = attrname.startsWith("xmlns:");
  -      if (isPrefix || attrname.equals("xmlns")) 
  +      if(attrname.charAt(0) == 'x')
         {
  -        int index = attrname.indexOf(':');
  -        String p = isPrefix ? attrname.substring(index+1) : "";
  -        if(m_emptyNamespace == pushNS)
  -          pushNS = new StringToStringTable();
  -        pushNS.put(p, atts.getValue(i));
  +        boolean isPrefix = attrname.startsWith("xmlns:");
  +        if (isPrefix || attrname.equals("xmlns")) 
  +        {
  +          int index = attrname.indexOf(':');
  +          String p = isPrefix ? attrname.substring(index+1) : "";
  +          if(m_emptyNamespace == pushNS)
  +            pushNS = new StringToStringTable();
  +          pushNS.put(p, atts.getValue(i));
  +        }
         }
       }
       namespaceTable.addElement(pushNS);
  @@ -562,10 +566,10 @@
       previousSibling = 0;
   
       // Append the attributes
  -    for (int i = 0; i < atts.getLength(); i++)
  +    for (int i = 0; i < nAttrs; i++)
       {
         String attrname = atts.getName(i);
  -      System.out.println(attrname);
  +
         // ***** OBSOLETE, SHOULD PRODUCE SUBTREE!
         String attrvalue = atts.getValue(i);
   
  
  
  
  1.6       +28 -1     xml-xalan/src/org/apache/xalan/xpath/dtm/DTMLiaison.java
  
  Index: DTMLiaison.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/dtm/DTMLiaison.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DTMLiaison.java   1999/12/13 07:46:58     1.5
  +++ DTMLiaison.java   1999/12/14 22:25:09     1.6
  @@ -73,6 +73,33 @@
   public class DTMLiaison extends XercesLiaison
   {
     /**
  +   * Flag to tell whether or not the parse is done on a seperate thread,
  +   * so the transform can occur at the same time.  The default 
  +   * is true.
  +   */
  +  private boolean m_doThreading = true;
  +  
  +  /**
  +   * Set whether or not the parse is done on a seperate thread,
  +   * so the transform can occur at the same time.  The default 
  +   * is true.
  +   */
  +  boolean getDoThreading()
  +  {
  +    return m_doThreading;
  +  }
  +  
  +  /**
  +   * Set whether or not the parse is done on a seperate thread,
  +   * so the transform can occur at the same time.  The default 
  +   * is true.
  +   */
  +  void setDoThreading(boolean b)
  +  {
  +    m_doThreading = b;
  +  }
  +  
  +  /**
      * Constructor that takes SAX ErrorHandler as an argument. The error 
handler
      * is registered with the XML Parser. Any XML-related errors will be 
reported
      * to the calling application using this error handler.
  @@ -166,7 +193,7 @@
           if(null != m_locale)
             parser.setLocale(m_locale);
           
  -        if(false)
  +        if(m_doThreading)
           {
             parser.parse(source);
           }
  
  
  
  1.9       +2 -0      
xml-xalan/src/org/apache/xalan/xslt/ElemTemplateElement.java
  
  Index: ElemTemplateElement.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/src/org/apache/xalan/xslt/ElemTemplateElement.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ElemTemplateElement.java  1999/12/13 08:22:54     1.8
  +++ ElemTemplateElement.java  1999/12/14 22:25:10     1.9
  @@ -538,6 +538,8 @@
              java.io.IOException,
              SAXException
     {
  +    processor.m_mustFlushStartDoc = true;
  +    processor.flushPending();
       DocumentHandler savedFListener = processor.m_flistener;
       StringWriter sw = new StringWriter();
       OutputFormat formatter = new OutputFormat("text", 
  
  
  
  1.5       +3 -1      xml-xalan/src/org/apache/xalan/xslt/FuncDocument.java
  
  Index: FuncDocument.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/FuncDocument.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FuncDocument.java 1999/12/14 20:51:21     1.4
  +++ FuncDocument.java 1999/12/14 22:25:10     1.5
  @@ -117,6 +117,7 @@
           base = execContext.findURIFromDoc(baseDoc);
       }
       XNodeSet nodes = new XNodeSet();
  +    MutableNodeList mnl = nodes.mutableNodeset();
       for(int i = 0; i < nRefs; i++)
       {
         String ref = (XObject.CLASS_NODESET == arg.getType())
  @@ -144,7 +145,8 @@
         }
         
         Document newDoc = getDoc(path, execContext, context, ref, base);
  -      nodes.mutableNodeset().addNode(newDoc);          
  +      // nodes.mutableNodeset().addNode(newDoc);     
  +      mnl.addNodeInDocOrder(newDoc, true, execContext);
       }
       return nodes;
     }
  
  
  

Reply via email to