xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zong...@apache.org
Subject cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/compiler Step.java
Date Wed, 15 Jun 2005 18:31:17 GMT
zongaro     2005/06/15 11:31:17

  Modified:    java/src/org/apache/xalan/xsltc/compiler Step.java
  Log:
  Patch for bug XALANJ-2097 from Nick Van den Bleeken
  (Nick.VandenBleeken () pandora ! be), reviewed by Henry Zongaro.
  
  The code generated for a path expression of the form $var/self::node() was
  incorrect.  It looked like the following, where "i" refers to the context node.
  
    new StepIterator(dtmaxisiterator1.cloneIterator(), new SingletonIterator(i));
  
  That's incorrect, because the SingletonIterator will only return the node used
  upon its instantiation, rather than the node provided from the parent step
  expression by the StepIterator.
  
  The SingletonIterator should only be used if the self::node() is not a step
  in a path expression.  In the case of a path expression, dom.getAxisIterator
  should be used to create the axis iterator instead.
  
  Revision  Changes    Path
  1.48      +20 -9     xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Step.java
  
  Index: Step.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Step.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- Step.java	15 Dec 2004 17:35:39 -0000	1.47
  +++ Step.java	15 Jun 2005 18:31:17 -0000	1.48
  @@ -250,6 +250,7 @@
   		return;
   	    }
   
  +	    SyntaxTreeNode parent = getParent();
   	    // Special case for '.'
   	    if (isAbbreviatedDot()) {
   		if (_type == Type.Node) {
  @@ -257,19 +258,29 @@
   		    il.append(methodGen.loadContextNode());
   		}
   		else {
  -		    // Wrap the context node in a singleton iterator if not.
  -		    int init = cpg.addMethodref(SINGLETON_ITERATOR,
  -						"<init>", "("+NODE_SIG+")V");
  -		    il.append(new NEW(cpg.addClass(SINGLETON_ITERATOR)));
  -		    il.append(DUP);
  -		    il.append(methodGen.loadContextNode());
  -		    il.append(new INVOKESPECIAL(init));
  +		    if (parent instanceof ParentLocationPath){
  +			// Wrap the context node in a singleton iterator if not.
  +			int init = cpg.addMethodref(SINGLETON_ITERATOR,
  +						    "<init>",
  +						    "("+NODE_SIG+")V");
  +			il.append(new NEW(cpg.addClass(SINGLETON_ITERATOR)));
  +			il.append(DUP);
  +			il.append(methodGen.loadContextNode());
  +			il.append(new INVOKESPECIAL(init));
  +		    } else {
  +			// DOM.getAxisIterator(int axis);
  +			int git = cpg.addInterfaceMethodref(DOM_INTF,
  +						"getAxisIterator",
  +						"(I)"+NODE_ITERATOR_SIG);
  +			il.append(methodGen.loadDOM());
  +			il.append(new PUSH(cpg, _axis));
  +			il.append(new INVOKEINTERFACE(git, 2));
  +		    }
   		}
   		return;
   	    }
   
   	    // Special case for /foo/*/bar
  -	    SyntaxTreeNode parent = getParent();
   	    if ((parent instanceof ParentLocationPath) &&
   		(parent.getParent() instanceof ParentLocationPath)) {
   		if ((_nodeType == NodeTest.ELEMENT) && (!_hadPredicates)) {
  
  
  

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


Mime
View raw message