sboag 01/07/30 13:09:22
Modified: java/src/org/apache/xpath/axes DescendantIterator.java
WalkerFactory.java
Log:
Fix addresses http://nagoya.apache.org/bugzilla/enter_bug.cgi?product=XalanJ2,
and a whole class of related problems.
Revision Changes Path
1.12 +24 -3
xml-xalan/java/src/org/apache/xpath/axes/DescendantIterator.java
Index: DescendantIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/DescendantIterator.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- DescendantIterator.java 2001/07/27 19:46:58 1.11
+++ DescendantIterator.java 2001/07/30 20:09:22 1.12
@@ -102,17 +102,36 @@
if (OpCodes.FROM_SELF == stepType)
{
orSelf = true;
- firstStepPos += 8;
+ // firstStepPos += 8;
}
else if(OpCodes.FROM_ROOT == stepType)
{
fromRoot = true;
// Ugly code... will go away when AST work is done.
- if(ops[firstStepPos+4] == OpCodes.FROM_DESCENDANTS_OR_SELF)
+ int nextStepPos = compiler.getNextStepPos(firstStepPos);
+ if(ops[nextStepPos] == OpCodes.FROM_DESCENDANTS_OR_SELF)
orSelf = true;
- firstStepPos += 8;
+ // firstStepPos += 8;
}
+ // Find the position of the last step.
+ int nextStepPos = firstStepPos;
+ while(true)
+ {
+ nextStepPos = compiler.getNextStepPos(nextStepPos);
+ if(nextStepPos > 0)
+ {
+ int stepOp = compiler.getOp(nextStepPos);
+ if(OpCodes.ENDOP != stepOp)
+ firstStepPos = nextStepPos;
+ else
+ break;
+ }
+ else
+ break;
+
+ }
+
// Fix for http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1336
if((analysis & WalkerFactory.BIT_CHILD) != 0)
orSelf = false;
@@ -346,6 +365,8 @@
String localName = getLocalName();
String namespace = getNamespace();
int what = m_whatToShow;
+
+ // System.out.print(" (DescendantIterator) ");
// System.out.println("what: ");
// NodeTest.debugWhatToShow(what);
1.19 +27 -7
xml-xalan/java/src/org/apache/xpath/axes/WalkerFactory.java
Index: WalkerFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/WalkerFactory.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- WalkerFactory.java 2001/07/28 00:26:00 1.18
+++ WalkerFactory.java 2001/07/30 20:09:22 1.19
@@ -286,9 +286,10 @@
// "/descendant-or-self::node()/table[3]" in order for the indexes
// to work right.
else if (isOptimizableForDescendantIterator(compiler, firstStepPos, 0)
- && getStepCount(analysis) <= 3
- && walksDescendants(analysis)
- && walksSubtreeOnlyFromRootOrContext(analysis))
+ // && getStepCount(analysis) <= 3
+ // && walksDescendants(analysis)
+ // && walksSubtreeOnlyFromRootOrContext(analysis)
+ )
{
if (DEBUG_ITERATOR_CREATION)
diagnoseIterator("DescendantIterator", analysis, compiler);
@@ -556,8 +557,15 @@
boolean foundSelf = false;
boolean foundDS = false;
+ int nodeTestType = OpCodes.NODETYPE_NODE;
+
while (OpCodes.ENDOP != (stepType = ops[stepOpCodePos]))
{
+ // The DescendantIterator can only do one node test. If there's more
+ // than one, use another iterator.
+ if(nodeTestType != OpCodes.NODETYPE_NODE && nodeTestType !=
OpCodes.NODETYPE_ROOT)
+ return false;
+
stepCount++;
if(stepCount > 3)
return false;
@@ -609,11 +617,23 @@
throw new
RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER,
new Object[]{Integer.toString(stepType)})); //"Programmer's assertion: unknown
opcode: "
// + stepType);
}
+
+ nodeTestType = compiler.getStepTestType(stepOpCodePos);
- stepOpCodePos = compiler.getNextStepPos(stepOpCodePos);
+ int nextStepOpCodePos = compiler.getNextStepPos(stepOpCodePos);
- if (stepOpCodePos < 0)
+ if (nextStepOpCodePos < 0)
break;
+
+ if(OpCodes.ENDOP != ops[nextStepOpCodePos])
+ {
+ if(compiler.countPredicates(stepOpCodePos) > 0)
+ {
+ return false;
+ }
+ }
+
+ stepOpCodePos = nextStepOpCodePos;
}
return true;
@@ -873,8 +893,8 @@
StepPattern attrPat = new StepPattern(whatToShow,
pat.getNamespace(),
pat.getLocalName(),
- //newAxis, pat.getPredicateAxis);
- newAxis, 0); // don't care
about the predicate axis
+ //newAxis, pat.getPredicateAxis);
+ newAxis, 0); // don't care
about the predicate axis
XNumber score = pat.getStaticScore();
pat.setNamespace(null);
pat.setLocalName(NodeTest.WILD);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]