morten 01/09/21 04:55:55
Modified: java/src/org/apache/xalan/xsltc DOM.java
java/src/org/apache/xalan/xsltc/compiler Constants.java
Step.java
java/src/org/apache/xalan/xsltc/dom DOMAdapter.java
DOMImpl.java MultiDOM.java NthIterator.java
Log:
Two fixes in this one. One to make sure that the context-node is set correctly
when applying templates using an iterator that has a predicate that tests on
'.' (the current node), such as select="foo/bar[. = 'blob']". The other fix
is for the nth position iterator, that failed to count to n backwards in
cases when the underlying iterator was reverse.
PR: bugzilla 2954 (two bugs in one, really)
Obtained from: n/a
Submitted by: [EMAIL PROTECTED]
Reviewed by: [EMAIL PROTECTED]
Revision Changes Path
1.5 +6 -2 xml-xalan/java/src/org/apache/xalan/xsltc/DOM.java
Index: DOM.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/DOM.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DOM.java 2001/09/21 09:39:38 1.4
+++ DOM.java 2001/09/21 11:55:55 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DOM.java,v 1.4 2001/09/21 09:39:38 morten Exp $
+ * @(#)$Id: DOM.java,v 1.5 2001/09/21 11:55:55 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -84,6 +84,10 @@
public final static int NULL = 0;
// index of root node
public final static int ROOTNODE = 1;
+
+ // used by some node iterators to know which node to return
+ public final static int RETURN_CURRENT = 0;
+ public final static int RETURN_PARENT = 1;
/** returns singleton iterator containg the document root */
public NodeIterator getIterator();
@@ -95,7 +99,7 @@
public NodeIterator getTypedAxisIterator(final int axis, final int type);
public NodeIterator getNthDescendant(int node, int n);
public NodeIterator getNamespaceAxisIterator(final int axis, final int
ns);
- public NodeIterator getNodeValueIterator(NodeIterator iter,
+ public NodeIterator getNodeValueIterator(NodeIterator iter, int
returnType,
String value, boolean op);
public NodeIterator orderNodes(NodeIterator source, int node);
public String getNodeName(final int node);
1.14 +2 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java
Index: Constants.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Constants.java 2001/08/27 12:38:32 1.13
+++ Constants.java 2001/09/21 11:55:55 1.14
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Constants.java,v 1.13 2001/08/27 12:38:32 morten Exp $
+ * @(#)$Id: Constants.java,v 1.14 2001/09/21 11:55:55 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -470,7 +470,7 @@
public static final String GET_NODE_VALUE_ITERATOR
= "getNodeValueIterator";
public static final String GET_NODE_VALUE_ITERATOR_SIG
- = "("+NODE_ITERATOR_SIG+STRING_SIG+"Z)"+NODE_ITERATOR_SIG;
+ = "("+NODE_ITERATOR_SIG+"I"+STRING_SIG+"Z)"+NODE_ITERATOR_SIG;
public static final int POSITION_INDEX = 2;
public static final int LAST_INDEX = 3;
1.11 +4 -2
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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Step.java 2001/09/20 14:33:30 1.10
+++ Step.java 2001/09/21 11:55:55 1.11
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Step.java,v 1.10 2001/09/20 14:33:30 morten Exp $
+ * @(#)$Id: Step.java,v 1.11 2001/09/21 11:55:55 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -382,6 +382,7 @@
// and place the node test on top of the resulting iterator
if (step.isAbbreviatedDot()) {
translate(classGen, methodGen);
+ il.append(new ICONST(DOM.RETURN_CURRENT));
}
// Otherwise we create a parent location path with this Step and
// the predicates Step, and place the node test on top of that
@@ -392,12 +393,13 @@
}
catch (TypeCheckError e) { }
path.translate(classGen, methodGen);
+ il.append(new ICONST(DOM.RETURN_PARENT));
}
predicate.translate(classGen, methodGen);
int iter = cpg.addInterfaceMethodref(DOM_INTF,
GET_NODE_VALUE_ITERATOR,
GET_NODE_VALUE_ITERATOR_SIG);
- il.append(new INVOKEINTERFACE(iter, 4));
+ il.append(new INVOKEINTERFACE(iter, 5));
}
// Handle '//*[n]' expression
else if (predicate.isNthDescendant()) {
1.5 +3 -3
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java
Index: DOMAdapter.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DOMAdapter.java 2001/09/21 09:39:38 1.4
+++ DOMAdapter.java 2001/09/21 11:55:55 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DOMAdapter.java,v 1.4 2001/09/21 09:39:38 morten Exp $
+ * @(#)$Id: DOMAdapter.java,v 1.5 2001/09/21 11:55:55 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -152,9 +152,9 @@
return _domImpl.getNthDescendant(node, n);
}
- public NodeIterator getNodeValueIterator(NodeIterator iterator,
+ public NodeIterator getNodeValueIterator(NodeIterator iterator, int type,
String value, boolean op) {
- return _domImpl.getNodeValueIterator(iterator, value, op);
+ return _domImpl.getNodeValueIterator(iterator, type, value, op);
}
public NodeIterator orderNodes(NodeIterator source, int node) {
1.29 +12 -6
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.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- DOMImpl.java 2001/09/21 09:39:38 1.28
+++ DOMImpl.java 2001/09/21 11:55:55 1.29
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DOMImpl.java,v 1.28 2001/09/21 09:39:38 morten Exp $
+ * @(#)$Id: DOMImpl.java,v 1.29 2001/09/21 11:55:55 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -975,6 +975,7 @@
public void gotoMark() {
_node = _markedNode;
}
+
} // end of PrecedingSiblingIterator
@@ -994,7 +995,7 @@
int node;
while ((node = super.next()) != NULL && _type[node] != _nodeType) {
}
- return node;
+ return returnNode(node);
}
} // end of PrecedingSiblingIterator
@@ -1524,10 +1525,12 @@
private String _value;
private boolean _op;
private final boolean _isReverse;
+ private int _returnType = RETURN_PARENT;
- public NodeValueIterator(NodeIterator source,
+ public NodeValueIterator(NodeIterator source, int returnType,
String value, boolean op) {
_source = source;
+ _returnType = returnType;
_value = value;
_op = op;
_isReverse = source.isReverse();
@@ -1563,7 +1566,10 @@
while ((node = _source.next()) != END) {
String val = getNodeValue(node);
if (_value.equals(val) == _op) {
- return _parent[node];
+ if (_returnType == RETURN_CURRENT)
+ return returnNode(node);
+ else
+ return returnNode(_parent[node]);
}
}
return END;
@@ -1586,9 +1592,9 @@
}
}
- public NodeIterator getNodeValueIterator(NodeIterator iterator,
+ public NodeIterator getNodeValueIterator(NodeIterator iterator, int type,
String value, boolean op) {
- return(new NodeValueIterator(iterator, value, op));
+ return(new NodeValueIterator(iterator, type, value, op));
}
/**************************************************************
1.7 +3 -3
xml-xalan/java/src/org/apache/xalan/xsltc/dom/MultiDOM.java
Index: MultiDOM.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/MultiDOM.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- MultiDOM.java 2001/09/21 09:39:38 1.6
+++ MultiDOM.java 2001/09/21 11:55:55 1.7
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: MultiDOM.java,v 1.6 2001/09/21 09:39:38 morten Exp $
+ * @(#)$Id: MultiDOM.java,v 1.7 2001/09/21 11:55:55 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -234,9 +234,9 @@
return _adapters[node>>>24].getNthDescendant(node & CLR, n);
}
- public NodeIterator getNodeValueIterator(NodeIterator iterator,
+ public NodeIterator getNodeValueIterator(NodeIterator iterator, int type,
String value, boolean op) {
- return _adapters[0].getNodeValueIterator(iterator, value, op);
+ return _adapters[0].getNodeValueIterator(iterator, type, value, op);
}
public NodeIterator getNamespaceAxisIterator(final int axis, final int
ns) {
1.2 +13 -3
xml-xalan/java/src/org/apache/xalan/xsltc/dom/NthIterator.java
Index: NthIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/NthIterator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NthIterator.java 2001/04/17 18:52:34 1.1
+++ NthIterator.java 2001/09/21 11:55:55 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: NthIterator.java,v 1.1 2001/04/17 18:52:34 sboag Exp $
+ * @(#)$Id: NthIterator.java,v 1.2 2001/09/21 11:55:55 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -68,13 +68,14 @@
public final class NthIterator extends NodeIteratorBase {
// ...[N]
- private final int _position;
private final NodeIterator _source;
+ private int _position = 1;
+ private int _n = 0;
private boolean _ready;
public NthIterator(NodeIterator source, int n) {
_source = source;
- _position = n;
+ _n = n;
}
public int next() {
@@ -93,6 +94,15 @@
public NodeIterator setStartNode(final int node) {
_source.setStartNode(node);
+ // Make sure we count backwards if the iterator is reverse
+ if (_source.isReverse()) {
+ int last = _source.getLast();
+ _position = (last - _n) + 1;
+ if (_position < 1) _position = 1;
+ }
+ else {
+ _position = _n;
+ }
_ready = true;
return this;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]