santiagopg 02/05/06 06:53:22
Modified: java/src/org/apache/xalan/xsltc/compiler
AncestorPattern.java Mode.java ParentPattern.java
StepPattern.java
Log:
Fixed a few problems with ancestor patterns (//) and patterns with
explicit priorities.
Revision Changes Path
1.5 +10 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AncestorPattern.java
Index: AncestorPattern.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AncestorPattern.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AncestorPattern.java 1 Feb 2002 20:07:08 -0000 1.4
+++ AncestorPattern.java 6 May 2002 13:53:22 -0000 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: AncestorPattern.java,v 1.4 2002/02/01 20:07:08 tmiller Exp $
+ * @(#)$Id: AncestorPattern.java,v 1.5 2002/05/06 13:53:22 santiagopg Exp $
*
* The Apache Software License, Version 1.1
*
@@ -94,6 +94,7 @@
public boolean isWildcard() {
//!!! can be wildcard
+ // return _right.isWildcard();
return false;
}
@@ -106,7 +107,9 @@
}
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
- if (_left != null) _left.typeCheck(stable);
+ if (_left != null) {
+ _left.typeCheck(stable);
+ }
return _right.typeCheck(stable);
}
@@ -133,6 +136,11 @@
}
else {
_right.translate(classGen, methodGen);
+
+ if (_right instanceof AncestorPattern) {
+ il.append(methodGen.loadDOM());
+ il.append(SWAP);
+ }
}
if (_left != null) {
1.21 +34 -14
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.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- Mode.java 3 May 2002 14:17:32 -0000 1.20
+++ Mode.java 6 May 2002 13:53:22 -0000 1.21
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Mode.java,v 1.20 2002/05/03 14:17:32 santiagopg Exp $
+ * @(#)$Id: Mode.java,v 1.21 2002/05/06 13:53:22 santiagopg Exp $
*
* The Apache Software License, Version 1.1
*
@@ -195,30 +195,30 @@
_templates.addElement(template);
}
- /*
private Vector quicksort(Vector templates, int p, int r) {
- while (p < r) {
+ if (p < r) {
final int q = partition(templates, p, r);
quicksort(templates, p, q);
- p = q + 1;
+ quicksort(templates, q + 1, r);
}
return templates;
}
private int partition(Vector templates, int p, int r) {
- final Template x = (Template)templates.elementAt((p + r) >>> 1);
+ final Template x = (Template)templates.elementAt(p);
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)
+ 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);
+ }
+ else {
+ return j;
+ }
}
}
- */
/**
* Process all the test patterns in this mode
@@ -226,7 +226,27 @@
public void processPatterns(Hashtable keys) {
_keys = keys;
- //_templates = quicksort(_templates, 0, _templates.size() - 1);
+/*
+System.out.println("Before Sort " + _name);
+for (int i = 0; i < _templates.size(); i++) {
+ System.out.println("name = " +
((Template)_templates.elementAt(i)).getName());
+ System.out.println("pattern = " +
((Template)_templates.elementAt(i)).getPattern());
+ System.out.println("priority = " +
((Template)_templates.elementAt(i)).getPriority());
+ System.out.println("position = " +
((Template)_templates.elementAt(i)).getPosition());
+}
+*/
+
+ _templates = quicksort(_templates, 0, _templates.size() - 1);
+
+/*
+System.out.println("\n After Sort " + _name);
+for (int i = 0; i < _templates.size(); i++) {
+ System.out.println("name = " +
((Template)_templates.elementAt(i)).getName());
+ System.out.println("pattern = " +
((Template)_templates.elementAt(i)).getPattern());
+ System.out.println("priority = " +
((Template)_templates.elementAt(i)).getPriority());
+ System.out.println("position = " +
((Template)_templates.elementAt(i)).getPosition());
+}
+*/
// Traverse all templates
final Enumeration templates = _templates.elements();
@@ -724,7 +744,7 @@
if (_nodeTestSeq != null) {
// Compare priorities of node() and "*"
- double nodePrio = -0.5; //_nodeTestSeq.getPriority();
+ double nodePrio = _nodeTestSeq.getPriority();
int nodePos = _nodeTestSeq.getPosition();
double elemPrio = (0 - Double.MAX_VALUE);
int elemPos = Integer.MIN_VALUE;
@@ -1063,7 +1083,7 @@
if (_nodeTestSeq != null) {
// Compare priorities of node() and "*"
- double nodePrio = -0.5; //_nodeTestSeq.getPriority();
+ double nodePrio = _nodeTestSeq.getPriority();
int nodePos = _nodeTestSeq.getPosition();
double elemPrio = (0 - Double.MAX_VALUE);
int elemPos = Integer.MIN_VALUE;
1.4 +6 -1
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParentPattern.java
Index: ParentPattern.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParentPattern.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ParentPattern.java 1 Feb 2002 20:07:08 -0000 1.3
+++ ParentPattern.java 6 May 2002 13:53:22 -0000 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ParentPattern.java,v 1.3 2002/02/01 20:07:08 tmiller Exp $
+ * @(#)$Id: ParentPattern.java,v 1.4 2002/05/06 13:53:22 santiagopg Exp $
*
* The Apache Software License, Version 1.1
*
@@ -129,6 +129,11 @@
}
else {
_right.translate(classGen, methodGen);
+
+ if (_right instanceof AncestorPattern) {
+ il.append(methodGen.loadDOM());
+ il.append(SWAP);
+ }
}
final int getParent = cpg.addInterfaceMethodref(DOM_INTF,
1.16 +4 -7
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/StepPattern.java
Index: StepPattern.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/StepPattern.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- StepPattern.java 24 Apr 2002 17:03:15 -0000 1.15
+++ StepPattern.java 6 May 2002 13:53:22 -0000 1.16
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: StepPattern.java,v 1.15 2002/04/24 17:03:15 santiagopg Exp $
+ * @(#)$Id: StepPattern.java,v 1.16 2002/05/06 13:53:22 santiagopg Exp $
*
* The Apache Software License, Version 1.1
*
@@ -133,14 +133,11 @@
else {
switch(_nodeType) {
case -1:
- return(-0.25);
+ return -0.5; // node()
case 0:
- return(0.0);
+ return 0.0;
default:
- if (_nodeType >= NodeTest.GTYPE)
- return(0.0);
- else
- return(-0.5);
+ return (_nodeType >= NodeTest.GTYPE) ? 0.0 : -0.5;
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]