Fix for XALANJ-2384.
The code generated for the topLevel and transform methods of a translet was
generated using DTM.ROOT_NODE (i.e., zero) as the value of the root node for
the initial context. However, that is not a valid node handle.
The proper way of getting the handle of root of the initial input document is
through DOM.getIterator().next().
Patch was reviewed by Christine Li (jycli () ca ! ibm ! com)
diff --git a/src/org/apache/xalan/xsltc/compiler/Stylesheet.java b/src/org/apache/xalan/xsltc/compiler/Stylesheet.java
index e753fb5..c07981a 100644
--- a/src/org/apache/xalan/xsltc/compiler/Stylesheet.java
+++ b/src/org/apache/xalan/xsltc/compiler/Stylesheet.java
@@ -1162,7 +1162,12 @@
"setFilter",
"(Lorg/apache/xalan/xsltc/StripFilter;)V");
- il.append(new PUSH(cpg, DTM.ROOT_NODE));
+ final int gitr = cpg.addInterfaceMethodref(DOM_INTF,
+ "getIterator",
+ "()"+NODE_ITERATOR_SIG);
+ il.append(toplevel.loadDOM());
+ il.append(new INVOKEINTERFACE(gitr, 1));
+ il.append(toplevel.nextNode());
current.setStart(il.append(new ISTORE(current.getIndex())));
// Create a new list containing variables/params + keys
@@ -1406,7 +1411,12 @@
il.append(new PUTFIELD(domField));
// continue with globals initialization
- il.append(new PUSH(cpg, DTM.ROOT_NODE));
+ final int gitr = cpg.addInterfaceMethodref(DOM_INTF,
+ "getIterator",
+ "()"+NODE_ITERATOR_SIG);
+ il.append(transf.loadDOM());
+ il.append(new INVOKEINTERFACE(gitr, 1));
+ il.append(transf.nextNode());
current.setStart(il.append(new ISTORE(current.getIndex())));
// Transfer the output settings to the output post-processor