Disclaimer: I've verified that the following COMPILES against both the
xalan-2.0.1.jar contained within the xml-xindice cvs AND against the
lastest xml-xalan2 compiled from cvs.  I've done NO execution testing.
However, based on prior discussions with the Xalan team, I have reason to
believe that this change may actually improve performance under both
versions.  I don't pretend that this will solve the overall performance
problems you apparently are seeing with the latest xalan developer
releases, but at least by being version agnostic, your users can choose the
version that best suits their needs.

Index: XPathQueryResolver.java
===================================================================
RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/core/query/XPathQueryResolver.java,v
retrieving revision 1.1
diff -u -r1.1 XPathQueryResolver.java
--- XPathQueryResolver.java   2001/12/06 21:00:14  1.1
+++ XPathQueryResolver.java   2001/12/07 20:51:34
@@ -70,6 +70,7 @@
 import org.apache.xindice.xml.dom.*;

 import org.w3c.dom.*;
+import org.w3c.dom.traversal.NodeIterator;

 import java.util.*;

@@ -964,9 +965,7 @@

       public Key[] keySet;
       public int keyPos = 0;
-      public NodeList nl;
-      public int nlPos = 0;
-      public int nlSize = 0;
+      public NodeIterator ni;
       public Node node;

       public ResultSet(Collection context, PrefixResolver pr, Key[] keySet, 
String query) {
@@ -1015,14 +1014,10 @@
                      xp = new XPath(query, null, pfx, XPath.SELECT, errors);
                }

-               nl = xp.execute(xpc, n, pfx).mutableNodeset();
+               ni = xp.execute(xpc, n, pfx).nodeset();

-               nlSize = nl.getLength();
-               if ( nlSize == 0 )
-                  continue;
-               else {
-                  nlPos = 1;
-                  node = nl.item(0);
+               node = ni.nextNode();
+               if ( node != null ) {
                   break;
                }
             }
@@ -1039,9 +1034,8 @@
       public Node getNextNode() {
          Node n = node;

-         if ( nlPos < nlSize )
-            node = nl.item(nlPos++);
-         else
+         node = ni.nextNode();
+         if ( node == null )
             prepareNextNode();

          return n;

- Sam Ruby

Reply via email to