villard 2003/07/14 08:38:17
Modified: java/xpath_rwapi/src2/org/apache/xpath Tag: xslt20
XPathUtilities.java
Log:
include "node()" in the list of expr that may match the document node
Revision Changes Path
No revision
No revision
1.1.2.2 +23 -3
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/Attic/XPathUtilities.java
Index: XPathUtilities.java
===================================================================
RCS file:
/home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/Attic/XPathUtilities.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- XPathUtilities.java 14 Jul 2003 15:25:14 -0000 1.1.2.1
+++ XPathUtilities.java 14 Jul 2003 15:38:17 -0000 1.1.2.2
@@ -59,8 +59,10 @@
package org.apache.xpath;
import org.apache.xpath.expression.Expr;
+import org.apache.xpath.expression.NodeTest;
import org.apache.xpath.expression.OperatorExpr;
import org.apache.xpath.expression.PathExpr;
+import org.apache.xpath.expression.StepExpr;
/**
* A collection of utility methods for XPath.
@@ -71,7 +73,10 @@
{
/**
- * Return true whether the specified expression matches document node
+ * Return true whether the specified expression matches document node.
+ * The test is performed statically, therefore there is no guarantee
+ * that the expression will indeed match the document node at runtime.
+ * (example: node()).
* @param Expr
* @return boolean
*/
@@ -95,7 +100,22 @@
case Expr.PATH_EXPR :
PathExpr p = (PathExpr) expr;
// TODO: revisit after implementation of
fn:root(...)=> operandCount == 1
- result = p.isAbsolute() && p.getOperandCount()
== 0;
+ result =
+ (p.isAbsolute() &&
p.getOperandCount() == 0) // '/'
+ || (p.getOperandCount() == 1 && isMatchDocumentNode(p.getOperand(0)));
+
+ break;
+ case Expr.STEP :
+ StepExpr s = (StepExpr) expr;
+ try
+ {
+ result = s.getNodeTest().isKindTest()
+ &&
s.getNodeTest().getKindTest() == NodeTest.ANY_KIND_TEST;
+ } catch (XPathException e)
+ {
+ // impossible
+ result = false;
+ }
break;
case Expr.COMBINE_EXPR : // Union, intersect, except
OperatorExpr c = (OperatorExpr) expr;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]