morten 01/10/09 08:37:57
Modified: java/src/org/apache/xalan/xsltc/compiler
ParentLocationPath.java Step.java
java/src/org/apache/xalan/xsltc/dom DOMImpl.java
Log:
Made the preceding iterator reverse (as it should be) and cleaned up some
more code. Added some code to handle specific combinations of iterators.
PR: bugzilla 2572
Obtained from: n/a
Submitted by: [EMAIL PROTECTED]
Reviewed by: [EMAIL PROTECTED]
Revision Changes Path
1.11 +5 -5
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParentLocationPath.java
Index: ParentLocationPath.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParentLocationPath.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ParentLocationPath.java 2001/10/09 12:08:09 1.10
+++ ParentLocationPath.java 2001/10/09 15:37:57 1.11
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ParentLocationPath.java,v 1.10 2001/10/09 12:08:09 morten Exp $
+ * @(#)$Id: ParentLocationPath.java,v 1.11 2001/10/09 15:37:57 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -202,10 +202,10 @@
// This is a special case for the //* path with or without predicates
if ((_path instanceof Step) && (_step instanceof Step)) {
- final Step path = (Step)_path;
- final Step step = (Step)_step;
- if ((path.getAxis() == Axis.DESCENDANTORSELF) &&
- (step.getAxis() == Axis.CHILD)) {
+ final int path = ((Step)_path).getAxis();
+ final int step = ((Step)_step).getAxis();
+ if ((path == Axis.DESCENDANTORSELF && step == Axis.CHILD) ||
+ (path == Axis.PRECEDING && step == Axis.PARENT)) {
final int incl = cpg.addMethodref(STEP_ITERATOR_CLASS,
"includeSelf",
"()"+NODE_ITERATOR_SIG);
1.22 +3 -3
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.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- Step.java 2001/10/09 12:08:09 1.21
+++ Step.java 2001/10/09 15:37:57 1.22
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Step.java,v 1.21 2001/10/09 12:08:09 morten Exp $
+ * @(#)$Id: Step.java,v 1.22 2001/10/09 15:37:57 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -205,7 +205,7 @@
else {
// Special case for '@attr' with no parent or predicates
if ((_axis == Axis.ATTRIBUTE) && (_nodeType!=NodeTest.ATTRIBUTE) &&
- (!hasParentPattern()) && (!hasPredicates())) {
+ (!hasParentPattern()) && (_hadPredicates)) {
_type = Type.Node;
}
else {
@@ -254,6 +254,7 @@
if (parent instanceof ApplyImports) return true;
if (parent instanceof ApplyTemplates) return true;
if (parent instanceof ForEach) return true;
+ if (parent instanceof FilterParentPath) return true;
// No not order node set if descendant of these elements:
if (parent instanceof ValueOf) return false;
@@ -384,7 +385,6 @@
orderIterator(classGen, methodGen);
break;
}
-
}
}
1.39 +10 -29
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java
Index: DOMImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- DOMImpl.java 2001/10/08 07:47:18 1.38
+++ DOMImpl.java 2001/10/09 15:37:57 1.39
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DOMImpl.java,v 1.38 2001/10/08 07:47:18 morten Exp $
+ * @(#)$Id: DOMImpl.java,v 1.39 2001/10/09 15:37:57 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -1047,10 +1047,7 @@
private class PrecedingIterator extends NodeIteratorBase {
private int _node = 0;
- private int[] _stack = new int[8];
- private int _sp = 0;
- private int _spStart = 0;
- private int _spMark = 0;
+ private int _mom = 0;
public boolean isReverse() {
return true;
@@ -1071,52 +1068,36 @@
public NodeIterator setStartNode(int node) {
if (_isRestartable) {
- _startNode = node;
- _node = ROOTNODE;
- int parent = node;
- while ((parent = _parent[parent]) > ROOTNODE) {
- if (_sp == _stack.length) {
- final int[] stack = new int[_sp + 4];
- System.arraycopy(_stack, 0, stack, 0, _sp);
- _stack = stack;
- }
- _stack[_sp++] = parent;
- }
- _sp--;
- _spStart = _sp;
+ _node = _startNode = node;
+ _mom = _parent[_startNode];
return resetPosition();
}
return this;
}
public int next() {
- // Advance node index and check if all nodes have been returned.
- while (++_node < _startNode) {
- // Check if we reached one of the base node's ancestors
- if ((_sp < 0) || (_node < _stack[_sp]))
- return returnNode(_node);
- // Anvance past the next ancestor node
- _sp--;
+ while (--_node > ROOTNODE) {
+ if (_node < _mom) _mom = _parent[_mom];
+ if (_node != _mom) return returnNode(_node);
}
return(NULL);
}
// redefine NodeIteratorBase's reset
public NodeIterator reset() {
- _node = ROOTNODE;
- _spStart = _sp;
+ _node = _startNode;
+ _mom = _parent[_startNode];
return resetPosition();
}
public void setMark() {
_markedNode = _node;
- _spMark = _sp;
}
public void gotoMark() {
_node = _markedNode;
- _sp = _spMark;
}
+
} // end of PrecedingIterator
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]