villard 2003/07/11 14:29:27
Modified: java/xpath_rwapi/src2/org/apache/xpath/impl Tag: xslt20
StepExprImpl.java OperatorImpl.java
java/xpath_rwapi/src2/org/apache/xpath/expression Tag:
xslt20 OperatorExpr.java PathExpr.java
StepExpr.java InstanceOfExpr.java
ExpressionFactory.java Expr.java
Log:
Many improvements in the javadoc. In particular, a mapping table between
XPath expression types and XPath API types is provided.
Other important change: the cloneStep method in StepExpr has been removed. It
was redundant with cloneExpression
Revision Changes Path
No revision
No revision
1.1.2.6 +0 -10
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/StepExprImpl.java
Index: StepExprImpl.java
===================================================================
RCS file:
/home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/StepExprImpl.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- StepExprImpl.java 24 Jun 2003 21:09:07 -0000 1.1.2.5
+++ StepExprImpl.java 11 Jul 2003 21:29:26 -0000 1.1.2.6
@@ -69,8 +69,6 @@
/**
* Default implementation of step.
- * %review% step is not an expression by itself: it's always ebbeded in path
expression.
- * So make it inherit of SimpleNode?
*/
public class StepExprImpl extends ExprImpl implements StepExpr
{
@@ -276,14 +274,6 @@
}
return (Expr) m_children[0];
- }
-
- /**
- * @see org.apache.xpath.expression.StepExpr#cloneStep()
- */
- public StepExpr cloneStep()
- {
- return new StepExprImpl(this);
}
/**
1.1.2.7 +1 -3
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/OperatorImpl.java
Index: OperatorImpl.java
===================================================================
RCS file:
/home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/OperatorImpl.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- OperatorImpl.java 2 Jul 2003 01:58:24 -0000 1.1.2.6
+++ OperatorImpl.java 11 Jul 2003 21:29:26 -0000 1.1.2.7
@@ -66,8 +66,6 @@
import org.apache.xpath.impl.parser.XPathConstants;
import org.apache.xpath.impl.parser.XPathTreeConstants;
-import java.security.InvalidParameterException;
-
/**
*
@@ -176,7 +174,7 @@
default:
// Invalid parameter
- throw new InvalidParameterException(
+ throw new IllegalArgumentException(
"The parameter value does not correspond to an operator
identifier"); // I16
}
}
No revision
No revision
1.1.2.3 +0 -18
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/OperatorExpr.java
Index: OperatorExpr.java
===================================================================
RCS file:
/home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/OperatorExpr.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- OperatorExpr.java 24 Jun 2003 21:09:08 -0000 1.1.2.2
+++ OperatorExpr.java 11 Jul 2003 21:29:26 -0000 1.1.2.3
@@ -69,24 +69,6 @@
* <li>path expressions (see <code>PathExpr</code>)</li>
* <li>Parenthesized expression</li>
* </ul>
- * <pre>
- * [14] UnionExpr ::= IntersectExceptExpr ( ("union" | "|")
IntersectExceptExpr )*
- * [15] IntersectExceptExpr ::= UnaryExpr ( ("intersect" | "except")
UnaryExpr )*
- * [12] AdditiveExpr ::= MultiplicativeExpr ( ("+" | "-")
MultiplicativeExpr )*
- * [13] MultiplicativeExpr ::= UnionExpr ( ("*" | "div" | "idiv" |
"mod") UnionExpr )*
- * [10] ComparisonExpr ::= RangeExpr ( (ValueComp| GeneralComp|
NodeComp| OrderComp) RangeExpr )?
- * [25] ValueComp ::= "eq" | "ne" | "lt" | "le" | "gt" | "ge"
- * [24] GeneralComp ::= "=" | "!=" | "<" | "<=" | ">" | ">="
- * [26] NodeComp ::= "is" | "isnot"
- * [27] OrderComp ::= "<<" | ">>"
- * [4] OrExpr ::= AndExpr ( "or" AndExpr )*
- * [5] AndExpr ::= ForExpr ( "and" ForExpr )*
- * [11] RangeExpr ::= AdditiveExpr ( "to" AdditiveExpr )*
- * [18] PathExpr ::= ("/" RelativePathExpr?) | ("//"
RelativePathExpr) | RelativePathExpr
- * [19] RelativePathExpr ::= StepExpr (("/" | "//") StepExpr)*
- * [46] ParenthesizedExpr ::= "(" ExprSequence? ")"
- * [25] ExprSequence ::= Expr ("," Expr)*
- * </pre>
* @see <a href="http://www.w3.org/TR/xpath20">XPath 2.0 Specification</href>
*/
public interface OperatorExpr extends Expr
1.1.2.2 +12 -5
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/PathExpr.java
Index: PathExpr.java
===================================================================
RCS file:
/home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/PathExpr.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- PathExpr.java 13 Mar 2003 20:28:17 -0000 1.1.2.1
+++ PathExpr.java 11 Jul 2003 21:29:26 -0000 1.1.2.2
@@ -56,17 +56,24 @@
package org.apache.xpath.expression;
/**
- * Represent Path expression.
- * [31] PathExpr ::= ("/" RelativePathExpr?)
- * | ("//" RelativePathExpr) | RelativePathExpr
- * [32] RelativePathExpr ::= StepExpr (("/" | "//") StepExpr)*
+ * Represents <em>path</em> expression. <quote>It can be used to locate
nodes within a tree.</quote>
+ * <p>A path expression consists of a series of [EMAIL PROTECTED] StepExpr}.
+ * It's a [EMAIL PROTECTED] OperatorExpr operator-based} expression
+ * with [EMAIL PROTECTED] OperatorExpr#SLASH_STEP} as the operator separator
+ * and [EMAIL PROTECTED] Expr#PATH_EXPR} as the operator type.
+ * </p>
+ * <p>"//" is always expanded as /descendant-or-self::node()/.</p>
+ * <p>In the same manner, the initial / is expanded as fn:root(self::node()).
+ * The convenient [EMAIL PROTECTED] #isAbsolute()} method may be used to
test whether
+ * or not the path expression is absolute.</p>
* @see <a href="http://www.w3.org/TR/xpath20/#id-path-expression">
* XPath 2.0 specification</a>
*/
public interface PathExpr extends OperatorExpr {
/**
- *
+ * Test whether the path is absolute or not
+ * @return boolean true whether absolute
*/
boolean isAbsolute();
}
1.1.2.4 +6 -19
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/StepExpr.java
Index: StepExpr.java
===================================================================
RCS file:
/home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/StepExpr.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- StepExpr.java 28 Mar 2003 22:47:41 -0000 1.1.2.3
+++ StepExpr.java 11 Jul 2003 21:29:26 -0000 1.1.2.4
@@ -59,13 +59,9 @@
/**
- * Represents step.
- * <pre>
- * [20] StepExpr ::= (ForwardStep | ReverseStep | Literal) Predicates
- * [39] ForwardStep ::= (ForwardAxis NodeTest) |
AbbreviatedForwardStep
- * [40] ReverseStep ::= (ReverseAxis NodeTest) |
AbbreviatedReverseStep
- * </pre>
- *
+ * Represents a step.
+ * <quote>A step generates a sequence of items and then filters the sequence
+ * by zero or more predicates.</quote>
* @see <a href="http://www.w3.org/TR/xpath20/#id-axis-steps">XPath 2.0
* specification</a>
*/
@@ -152,22 +148,19 @@
static final short AXIS_ANCESTOR_OR_SELF = 13;
/**
- * Returns true when the step is a forward test
- *
+ * Tells whether or not this step is a foward axis step
* @return boolean
*/
boolean isForwardStep();
/**
- * Returns true when the step is a reverse test
- *
+ * Tells whether or not this step is a reversed axis step
* @return boolean
*/
boolean isReversedStep();
/**
- * Tell whether this step is a primary expression.
- *
+ * Tells whether or not this step is a filter step.
* @return boolean
*/
boolean isPrimaryExpr();
@@ -249,10 +242,4 @@
* Remove the specified predicate
*/
void removePredicate(Expr predicate);
-
- /**
- * Clone this step
- * @return A clone of this step
- */
- StepExpr cloneStep();
}
1.1.2.3 +1 -2
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/InstanceOfExpr.java
Index: InstanceOfExpr.java
===================================================================
RCS file:
/home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/InstanceOfExpr.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- InstanceOfExpr.java 25 Mar 2003 23:46:08 -0000 1.1.2.2
+++ InstanceOfExpr.java 11 Jul 2003 21:29:26 -0000 1.1.2.3
@@ -59,8 +59,7 @@
/**
* Represents "instance of" expression.
- * @see <a href="http://www.w3.org/TR/xpath20/#id-instance-of">XPath 2.0
- * specification</a>
+ * @see <a href="http://www.w3.org/TR/xpath20/#id-instance-of">XPath 2.0
Specification</a>
*/
public interface InstanceOfExpr extends Expr {
1.1.2.7 +3 -2
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/ExpressionFactory.java
Index: ExpressionFactory.java
===================================================================
RCS file:
/home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/ExpressionFactory.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- ExpressionFactory.java 11 Jul 2003 19:09:26 -0000 1.1.2.6
+++ ExpressionFactory.java 11 Jul 2003 21:29:26 -0000 1.1.2.7
@@ -65,8 +65,9 @@
/**
- * Allows the creation of XPath expression either from string representation
or
- * by composing expressions.
+ * Constructors for XPath expressions.
+ * @author <a href="mailto:[EMAIL PROTECTED]">Lionel Villard</a>
+ * @version $Id$
*/
public interface ExpressionFactory
{
1.1.2.3 +238 -117
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/Expr.java
Index: Expr.java
===================================================================
RCS file:
/home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/Expr.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- Expr.java 26 Mar 2003 03:42:56 -0000 1.1.2.2
+++ Expr.java 11 Jul 2003 21:29:26 -0000 1.1.2.3
@@ -55,150 +55,271 @@
*/
package org.apache.xpath.expression;
-
/**
- * This interface represents an XPath Expression.
+ * Represents a XPath expression.
+ * <p>Use [EMAIL PROTECTED] #getExprType()} to query the expression type.
+ * More information about expression are obtained by casting it
+ * to its corresponding java type. Here the XPath expression type to Java
type mapping table:
+ * </p>
+ * <table cellpadding="2" cellspacing="2" border="1">
+ * <thead>
+ * <tr>
+ * <td>Expression type</td>
+ * <td>Java type</td>
+ * </tr>
+ * </thead>
+ * <tbody>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #PATH_EXPR}</td>
+ * <td>[EMAIL PROTECTED] PathExpr}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #LOGICAL_EXPR}</td>
+ * <td>[EMAIL PROTECTED] OperatorExpr}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #CONDITIONAL_EXPR}</td>
+ * <td>[EMAIL PROTECTED] ConditionalExpr}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #ITERATION_EXPR}</td>
+ * <td>[EMAIL PROTECTED] ForAndQuantifiedExpr}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #EVERY_EXPR}</td>
+ * <td>[EMAIL PROTECTED] ForAndQuantifiedExpr}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #SOME_EXPR}</td>
+ * <td>[EMAIL PROTECTED] ForAndQuantifiedExpr}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #COMPARISON_EXPR}</td>
+ * <td>[EMAIL PROTECTED] OperatorExpr}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #ARITHMETIC_EXPR}</td>
+ * <td>[EMAIL PROTECTED] OperatorExpr}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #SEQUENCE_EXPR}</td>
+ * <td>[EMAIL PROTECTED] OperatorExpr}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #COMBINE_EXPR}</td>
+ * <td>[EMAIL PROTECTED] OperatorExpr}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #LITERAL_EXPR}</td>
+ * <td>[EMAIL PROTECTED] Literal}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #FUNCTION_CALL_EXPR}</td>
+ * <td>[EMAIL PROTECTED] FunctionCall}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #VARIABLE_REF_EXPR}</td>
+ * <td>[EMAIL PROTECTED] Variable}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #RANGE_EXPR}</td>
+ * <td>[EMAIL PROTECTED] OperatorExpr}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #STEP}</td>
+ * <td>[EMAIL PROTECTED] StepExpr}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #INSTANCE_OF_EXPR}</td>
+ * <td>[EMAIL PROTECTED] InstanceOfExpr}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #UNARY_EXPR}</td>
+ * <td>[EMAIL PROTECTED] OperatorExpr}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #CAST_AS_EXPR}</td>
+ * <td>[EMAIL PROTECTED] CastOrTreatAsExpr}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #TREAT_AS_EXPR}</td>
+ * <td>[EMAIL PROTECTED] CastOrTreatAsExpr}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #CASTABLE_EXPR}</td>
+ * <td>[EMAIL PROTECTED] CastableAsExpr}</td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] #VALIDATE_EXPR}</td>
+ * <td>[EMAIL PROTECTED] ?}</td>
+ * </tr>
+ * </tbody>
+ * </table>
+ * <p>For example the following code snippet may be used to get the items of
+ * the expression e = (1, call(),(toto[/user], $author)):</p>
+ * <pre>
+ * void printItem(Expr e)
+ * {
+ * if (e.getExprType() == Expr.SEQUENCE_EXPR)
+ * {
+ * OperatorExpr expr = (OperatorExpr) e;
+ * for (int i = 0; i %lt; expr.getOperandCount(); i ++ )
+ * {
+ * printItem(expr.getOperand(i));
+ * }
+ * } else
+ * {
+ * System.out.println(e.getString(true) + " ");
+ * }
+ * }
+ * </pre>
+ * <p>Should produced the following result:</p>
* <pre>
- * [1] XPath ::= ExprSequence?
- * [3] Expr ::= OrExpr
- * [7] QuantifiedExpr ::= ((<"some" "$"> | <"every" "$">) VarName
"in" Expr ("," "$" VarName "in" Expr)* "satisfies")* IfExpr
- * [10] ComparisonExpr ::= RangeExpr ( (ValueComp | GeneralComp |
NodeComp | OrderComp) RangeExpr )?
- * [18] PathExpr ::= ("/" RelativePathExpr?) | ("//" RelativePathExpr)
| RelativePathExpr
- * </pre>
+ * 1 call() toto[/user] $author
+ * </pre>
+ * <p>XPath expressions are always fully expanded. For example, the
expression
+ * /a//b is expanded to fn:root(self::node())/descendant-or-self::node()/b.
+ * The number of steps is 3 (and not 2).
+ * </p>
+ * <p>
+ * An [EMAIL PROTECTED] Expr} object may be not a valid XPath expression but
a only a fragment.
+ * For example a [EMAIL PROTECTED] StepExpr} expression is a fragment but
can't be executed by
+ * itself. To be valid, the top level expression must be an expression
sequence.
+ * </p>
* @see <a
href="http://www.w3.org/TR/2002/WD-xpath20-20020816/#id-expressions">XPath 2.0
Specification</a>
- */
-public interface Expr extends Visitable {
+ * @author <a href="mailto:[EMAIL PROTECTED]">Lionel Villard</a>
+ * @version $Id$
+ */
+public interface Expr extends Visitable
+{
+
+ /**
+ * The expression is a path expression
+ */
+ static final short PATH_EXPR = 0;
- /**
- * The expression is a path expression
- */
- static final short PATH_EXPR = 0;
-
- /**
- * The expression is a logical expression.
- * Represents 'or' and 'and' expressions.
- */
+ /**
+ * The expression is a logical expression.
+ * Represents 'or' and 'and' expressions.
+ */
static final short LOGICAL_EXPR = 1;
-
- /**
- * The expression is a conditionnal expression (if)
- */
+
+ /**
+ * The expression is a conditionnal expression (if)
+ */
static final short CONDITIONAL_EXPR = 2;
-
- /**
- * The expression is an iteration expression (for)
- */
+
+ /**
+ * The expression is an iteration expression (for)
+ */
static final short ITERATION_EXPR = 3;
-
- /**
- * The expression is a quantified expression of type every
- */
+
+ /**
+ * The expression is a quantified expression of type every
+ */
static final short EVERY_EXPR = 4;
-
+
/**
* The expression is a quantified expression of type some
*/
static final short SOME_EXPR = 22;
-
- /**
- * The expression is a comparison expression type.
- * Includes value comparisons, general comparisons, node comparisons
- * and order comparisons.
- */
- static final short COMPARISON_EXPR = 5;
-
- /**
- * The expression is an arithmetic expression.
- * Includes arithmetic operators for addition, subtraction,
multiplication, division and modulus
- */
+
+ /**
+ * The expression is a comparison expression type.
+ * Includes value comparisons, general comparisons, node comparisons
+ * and order comparisons.
+ */
+ static final short COMPARISON_EXPR = 5;
+
+ /**
+ * The expression is an arithmetic expression.
+ * Includes arithmetic operators for addition, subtraction,
multiplication, division and modulus
+ */
static final short ARITHMETIC_EXPR = 6;
-
- /**
- * The expression is a sequence.
- */
+
+ /**
+ * The expression is a sequence.
+ */
static final short SEQUENCE_EXPR = 7;
-
- /**
- * The expression is a combine expression (union and intersection)
- */
+
+ /**
+ * The expression is a combine expression (union and intersection)
+ */
static final short COMBINE_EXPR = 8;
-
- /**
- * The expression is a validate expression
- */
+
+ /**
+ * The expression is a validate expression
+ */
static final short VALIDATE_EXPR = 10;
-
- /**
- * The expression is a literal expression
- */
+
+ /**
+ * The expression is a literal expression
+ */
static final short LITERAL_EXPR = 13;
- /**
- * The expression is a function call
- */
+ /**
+ * The expression is a function call
+ */
static final short FUNCTION_CALL_EXPR = 14;
- /**
- * The expression is a variable reference
- */
+ /**
+ * The expression is a variable reference
+ */
static final short VARIABLE_REF_EXPR = 15;
- /**
- * The expression is a range expression
- */
+ /**
+ * The expression is a range expression
+ */
static final short RANGE_EXPR = 16;
-
- /**
- * Step
- * %review% to remove since a step can't exist outside of path
- */
+
+ /**
+ * The expression is a step
+ */
static final short STEP = 17;
-
- /**
- * The expression is an instance of expression
- */
- static final short INSTANCE_OF_EXPR = 18;
-
- /**
- * The expression is an unary expression
- */
+
+ /**
+ * The expression is an instance of expression
+ */
+ static final short INSTANCE_OF_EXPR = 18;
+
+ /**
+ * The expression is an unary expression
+ */
static final short UNARY_EXPR = 19;
-
- /**
- * The expression is a cast as expression
- */
+
+ /**
+ * The expression is a cast as expression
+ */
static final short CAST_AS_EXPR = 20;
-
- /**
- * The expression is a castable expression
- */
+
+ /**
+ * The expression is a castable expression
+ */
static final short CASTABLE_EXPR = 21;
-
+
/**
- * The expression is a treat as expression
- */
- static final short TREAT_AS_EXPR = 22;
-
- /**
- * Gets the global expression type.
- * @return The type of this expression: one of the constants defined in
this
- * interface
- */
- short getExprType();
-
- /**
- * Clone the expression
- * @return A clone of this expression
- */
- Expr cloneExpression();
-
- /**
- * Gets the expression as a string (external form)
- * @param abbreviate Gets the string as an abbreviate form or not
- * @return The external form of this expression
- */
- String getString(boolean abbreviate);
-
-}
+ * The expression is a treat as expression
+ */
+ static final short TREAT_AS_EXPR = 22;
+ /**
+ * Gets the expression type.
+ * @return The type of this expression: one of the constants defined in
this
+ * interface
+ */
+ short getExprType();
+
+ /**
+ * Clone expression
+ * @return A clone of this expression
+ */
+ Expr cloneExpression();
+ /**
+ * Gets the expression as a string (external form)
+ * @param abbreviate Gets the string as an abbreviate form or not
+ * @return The external form of this expression
+ */
+ String getString(boolean abbreviate);
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]