You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mo...@apache.org on 2001/11/20 14:32:01 UTC
cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/compiler Mode.java Template.java xpath.cup
morten 01/11/20 05:32:01
Modified: java/src/org/apache/xalan/xsltc/compiler Mode.java
Template.java xpath.cup
Log:
Fix for nested parent location paths / filter parent paths with key() or
id() root. These paths would in some case returnt he root node when they
should not.
PR: bugzilla 4781
Obtained from: n/a
Submitted by: morten@xml.apache.org
Reviewed by: morten@xml.apache.org
Revision Changes Path
1.18 +29 -1 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Mode.java
Index: Mode.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Mode.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Mode.java 2001/11/08 10:23:39 1.17
+++ Mode.java 2001/11/20 13:32:01 1.18
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Mode.java,v 1.17 2001/11/08 10:23:39 morten Exp $
+ * @(#)$Id: Mode.java,v 1.18 2001/11/20 13:32:01 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -160,11 +160,39 @@
_templates.addElement(template);
}
+ /*
+ private Vector quicksort(Vector templates, int p, int r) {
+ while (p < r) {
+ final int q = partition(templates, p, r);
+ quicksort(templates, p, q);
+ p = q + 1;
+ }
+ return templates;
+ }
+
+ private int partition(Vector templates, int p, int r) {
+ final Template x = (Template)templates.elementAt((p + r) >>> 1);
+ int i = p - 1;
+ int j = r + 1;
+ while (true) {
+ while (x.compareTo((Template)templates.elementAt(--j)) < 0);
+ while (x.compareTo((Template)templates.elementAt(++i)) > 0);
+ if (i < j)
+ templates.set(j, templates.set(i, templates.elementAt(j)));
+ else
+ return(j);
+ }
+ }
+ */
+
/**
* Process all the test patterns in this mode
*/
public void processPatterns(Hashtable keys) {
_keys = keys;
+
+ //_templates = quicksort(_templates, 0, _templates.size() - 1);
+
// Traverse all templates
final Enumeration templates = _templates.elements();
while (templates.hasMoreElements()) {
1.15 +18 -1 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Template.java
Index: Template.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Template.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- Template.java 2001/10/30 08:42:55 1.14
+++ Template.java 2001/11/20 13:32:01 1.15
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Template.java,v 1.14 2001/10/30 08:42:55 morten Exp $
+ * @(#)$Id: Template.java,v 1.15 2001/11/20 13:32:01 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -146,6 +146,23 @@
public QName getModeName() {
return _mode;
+ }
+
+ /**
+ * Compare this template to another. First checks priority, then position.
+ */
+ public int compareTo(Object template) {
+ Template other = (Template)template;
+ if (_priority > other._priority)
+ return 1;
+ else if (_priority < other._priority)
+ return -1;
+ else if (_position > other._position)
+ return 1;
+ else if (_position < other._position)
+ return -1;
+ else
+ return 0;
}
private Hashtable _variables;
1.31 +3 -2 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath.cup
Index: xpath.cup
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath.cup,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- xpath.cup 2001/11/14 08:20:20 1.30
+++ xpath.cup 2001/11/20 13:32:01 1.31
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: xpath.cup,v 1.30 2001/11/14 08:20:20 morten Exp $
+ * @(#)$Id: xpath.cup,v 1.31 2001/11/20 13:32:01 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -490,7 +490,8 @@
Step step = new Step(Axis.DESCENDANTORSELF, NodeTest.ANODE, null);
FilterParentPath fpp = new FilterParentPath(fexp, step);
fpp = new FilterParentPath(fpp, rlp);
- fpp.setDescendantAxis();
+ if (!(fexp instanceof KeyCall))
+ fpp.setDescendantAxis();
RESULT = fpp;
:};
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org