You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by zo...@apache.org on 2006/06/07 21:54:33 UTC

svn commit: r412505 - in /xalan/java/trunk/src/org/apache/xalan/xsltc: compiler/Key.java runtime/AbstractTranslet.java

Author: zongaro
Date: Wed Jun  7 12:54:33 2006
New Revision: 412505

URL: http://svn.apache.org/viewvc?rev=412505&view=rev
Log:
Part of fix for XALANJ-2294.  When building a KeyIndex for keys or for IDs in
a document, the KeyIndex needs to be informed of the root node of the document
so that it can retrieve only nodes that are in the same document as the context
node and of node handles for nodes rather than the node identities, which will
be reused across different documents.

Reviewed by Christine Li (jycli () ca ! ibm ! com)

Modified:
    xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/Key.java
    xalan/java/trunk/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java

Modified: xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/Key.java
URL: http://svn.apache.org/viewvc/xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/Key.java?rev=412505&r1=412504&r2=412505&view=diff
==============================================================================
--- xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/Key.java (original)
+++ xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/Key.java Wed Jun  7 12:54:33 2006
@@ -160,10 +160,6 @@
 
 	// Get the 'parameter' from the stack and store it in a local var.
 	parentNode.setStart(il.append(new ISTORE(parentNode.getIndex())));	
-	il.append(methodGen.loadDOM());
-	il.append(new ILOAD(parentNode.getIndex()));	
-	il.append(new INVOKEINTERFACE(getNodeIdent, 2));
-	il.append(new ISTORE(parentNode.getIndex()));
 
 	// Save current node and current iterator on the stack
 	il.append(methodGen.loadCurrentNode());
@@ -272,11 +268,6 @@
 	    il.append(DUP_X1);
 	    il.append(methodGen.loadCurrentNode());
 	    _use.translate(classGen, methodGen);
-	    il.append(SWAP);
-	    il.append(methodGen.loadDOM());
-	    il.append(SWAP);
-	    il.append(new INVOKEINTERFACE(getNodeIdent, 2));
-	    il.append(SWAP);
 	    il.append(new INVOKEVIRTUAL(key));
 	    
 	    il.append(methodGen.loadDOM());

Modified: xalan/java/trunk/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java
URL: http://svn.apache.org/viewvc/xalan/java/trunk/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java?rev=412505&r1=412504&r2=412505&view=diff
==============================================================================
--- xalan/java/trunk/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java (original)
+++ xalan/java/trunk/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java Wed Jun  7 12:54:33 2006
@@ -123,6 +123,7 @@
      */
     public final DOMAdapter makeDOMAdapter(DOM dom)
 	throws TransletException {
+        setRootForKeys(dom.getDocument());
 	return new DOMAdapter(dom, namesArray, urisArray, typesArray, namespaceArray);
     }
 
@@ -309,7 +310,8 @@
      * The index contains the element node index (int) and Id value (String).
      */
     private final void buildIDIndex(DOM document) {
-        
+        setRootForKeys(document.getDocument());
+
         if (document instanceof DOMEnhancedForDTM) {
             DOMEnhancedForDTM enhancedDOM = (DOMEnhancedForDTM)document;
             
@@ -335,7 +337,10 @@
 
                 while (idValues.hasMoreElements()) {
             	    final Object idValue = idValues.nextElement();
-            	    final int element = ((Integer)elementsByID.get(idValue)).intValue();
+            	    final int element =
+                            document.getNodeHandle(
+                                        ((Integer)elementsByID.get(idValue))
+                                                .intValue());
 
             	    buildKeyIndex(ID_INDEX_NAME, element, idValue);
             	    hasIDValues = true;
@@ -408,6 +413,7 @@
     private Hashtable _keyIndexes = null;
     private KeyIndex  _emptyKeyIndex = null;
     private int       _indexSize = 0;
+    private int       _currentRootForKeys = 0;
 
     /**
      * This method is used to pass the largest DOM size to the translet.
@@ -427,7 +433,7 @@
     /**
      * Adds a value to a key/id index
      *   @param name is the name of the index (the key or ##id)
-     *   @param node is the node id of the node to insert
+     *   @param node is the node handle of the node to insert
      *   @param value is the value that will look up the node in the given index
      */
     public void buildKeyIndex(String name, int node, Object value) {
@@ -437,7 +443,7 @@
 	if (index == null) {
 	    _keyIndexes.put(name, index = new KeyIndex(_indexSize));
 	}
-	index.add(value, node);
+	index.add(value, node, _currentRootForKeys);
     }
 
     /**
@@ -478,6 +484,10 @@
 	}
 
 	return(index);
+    }
+
+    private void setRootForKeys(int root) {
+        _currentRootForKeys = root;
     }
 
     /**



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