villard 2003/07/14 11:28:39
Modified: java/xpath_rwapi/src2/org/apache/xpath/impl Tag: xslt20
StepExprImpl.java ExpressionFactoryImpl.java
OperatorImpl.java
java/xpath_rwapi/src2/org/apache/xpath/expression Tag:
xslt20 OperatorExpr.java Expr.java
java/xpath_rwapi/src2/org/apache/xpath Tag: xslt20
XPathUtilities.java
java/xpath_rwapi/src2/org/apache/xpath/test Tag: xslt20
TestSamples.xml
Log:
Javadoc for OperatorExpr
Range exprs and conbine exprs (union, ...) are now considered as sequence
expr.
Revision Changes Path
No revision
No revision
1.1.2.7 +1 -3
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.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- StepExprImpl.java 11 Jul 2003 21:29:26 -0000 1.1.2.6
+++ StepExprImpl.java 14 Jul 2003 18:28:38 -0000 1.1.2.7
@@ -404,9 +404,7 @@
{
ExprImpl p = (ExprImpl) getPrimaryExpr();
- if ((p.getExprType() == SEQUENCE_EXPR)
- || (p.getExprType() == COMBINE_EXPR)
- || (p.getExprType() == RANGE_EXPR))
+ if ((p.getExprType() == SEQUENCE_EXPR))
{
expr.append('(');
p.getString(expr, abbreviate);
1.1.2.8 +1 -1
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/ExpressionFactoryImpl.java
Index: ExpressionFactoryImpl.java
===================================================================
RCS file:
/home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/ExpressionFactoryImpl.java,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -u -r1.1.2.7 -r1.1.2.8
--- ExpressionFactoryImpl.java 11 Jul 2003 19:09:26 -0000 1.1.2.7
+++ ExpressionFactoryImpl.java 14 Jul 2003 18:28:38 -0000 1.1.2.8
@@ -138,7 +138,7 @@
* @see
org.apache.xpath.expression.ExpressionFactory#createCombineExpr(short)
*/
public OperatorExpr createCombineExpr(short type) {
- return new OperatorImpl(Expr.COMBINE_EXPR, type);
+ return new OperatorImpl(Expr.SEQUENCE_EXPR, type);
}
/**
1.1.2.8 +12 -13
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.7
retrieving revision 1.1.2.8
diff -u -r1.1.2.7 -r1.1.2.8
--- OperatorImpl.java 11 Jul 2003 21:29:26 -0000 1.1.2.7
+++ OperatorImpl.java 14 Jul 2003 18:28:38 -0000 1.1.2.8
@@ -134,7 +134,7 @@
case XPathTreeConstants.JJTUNIONEXPR:
case XPathTreeConstants.JJTINTERSECTEXCEPTEXPR:
case XPathTreeConstants.JJTPATTERN:
- m_exprType = COMBINE_EXPR;
+ m_exprType = SEQUENCE_EXPR;
// opType is not known yet
break;
@@ -166,8 +166,8 @@
break;
case XPathTreeConstants.JJTRANGEEXPR:
- m_exprType = RANGE_EXPR;
- m_opType = RANGE;
+ m_exprType = SEQUENCE_EXPR;
+ m_opType = TO;
break;
@@ -342,7 +342,9 @@
{
if (((m_exprType == SEQUENCE_EXPR)
&& (n.jjtGetNumChildren() > 0)
- && (n.jjtGetChild(0).getId() ==
XPathTreeConstants.JJTEXPRSEQUENCE))
+ && (((Expr) n.jjtGetChild(0)).getExprType() ==
SEQUENCE_EXPR)
+ && (((OperatorExpr)
n.jjtGetChild(0)).getOperatorType() == m_opType)
+ )
|| ((id == XPathTreeConstants.JJTPATTERN)
&& (n.jjtGetNumChildren() > 0)
&& (n.jjtGetChild(0).getId() ==
XPathTreeConstants.JJTPATTERN)))
@@ -387,8 +389,7 @@
/**
* Tell is spaces are needed around the operator
- *
- * @return DOCUMENT ME!
+ * @return
*/
protected boolean isSpaceNeeded()
{
@@ -398,8 +399,8 @@
/**
* Gets expression as external string representation
*
- * @param expr DOCUMENT ME!
- * @param abbreviate DOCUMENT ME!
+ * @param expr
+ * @param abbreviate
*/
public void getString(StringBuffer expr, boolean abbreviate)
{
@@ -417,7 +418,7 @@
op = (ExprImpl) getOperand(i);
if ((op.getExprType() == ARITHMETIC_EXPR)
- || (op.getExprType() == COMBINE_EXPR))
+ || (op.getExprType() == SEQUENCE_EXPR))
{
expr.append('(');
}
@@ -425,7 +426,7 @@
op.getString(expr, abbreviate);
if ((op.getExprType() == ARITHMETIC_EXPR)
- || (op.getExprType() == COMBINE_EXPR))
+ || (op.getExprType() == SEQUENCE_EXPR))
{
expr.append(')');
}
@@ -447,9 +448,7 @@
}
}
- /**
- * @see org.apache.xpath.impl.parser.SimpleNode#processToken(Token)
- */
+
public void processToken(Token token)
{
switch (token.kind)
No revision
No revision
1.1.2.4 +145 -87
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.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- OperatorExpr.java 11 Jul 2003 21:29:26 -0000 1.1.2.3
+++ OperatorExpr.java 14 Jul 2003 18:28:38 -0000 1.1.2.4
@@ -59,193 +59,249 @@
/**
- * Represents any expressions with one, two or more operands. This includes
the following XPath features:
+ * Represents any expressions which combine one or many operands under
+ * a single operator.
+ * The following XPath constructors are represented by this interface:
* <ul>
- * <li>combining sequences</li>
- * <li>unary and binary arithmetics expressions</li>
- * <li>comparison expressions</li>
- * <li>logical expressions</li>
- * <li>range expressions</li>
- * <li>path expressions (see <code>PathExpr</code>)</li>
- * <li>Parenthesized expression</li>
+ * <li><strong>Sequence expression</strong>:
+ * <ul>
+ * <li><strong>By constructing</strong>:
+ * <ul>
+ * <li>Expression type: [EMAIL PROTECTED] Expr#SEQUENCE_EXPR}</li>
+ * <li>Operator type: [EMAIL PROTECTED] OperatorExpr#COMMA} or
[EMAIL PROTECTED] OperatorExpr#TO}</li>
+ * <li>Example: <code>(10, 1, 2, 3, 4)</code>, <code>1 to
10</code></li>
+ * </ul>
+ * </li>
+ *
+ * <li><strong>By combining</strong>:
+ * <ul>
+ * <li>Expression type: [EMAIL PROTECTED] Expr#SEQUENCE_EXPR}</li>
+ * <li>Operator type: [EMAIL PROTECTED]
OperatorExpr#UNION_COMBINE} or
+ * [EMAIL PROTECTED]
OperatorExpr#INTERSECT_COMBINE} or
+ * [EMAIL PROTECTED]
OperatorExpr#EXCEPT_COMBINE}</li>
+ * <li>Example: <code>$seq2 union $seq3</code></li>
+ * </ul>
+ * </li>
+ * </ul>
+ * </li>
+ * <li><strong>Arithmetic expressions</strong>:
+ * <ul>
+ * <li><strong>Unary expression</strong>:
+ * <ul>
+ * <li>Expression type: [EMAIL PROTECTED] Expr#ARITHMETIC_EXPR}</li>
+ * <li>Operator type: [EMAIL PROTECTED] OperatorExpr#PLUS_UNARY}
or [EMAIL PROTECTED] OperatorExpr#MINUS_UNARY}</li>
+ * <li>Example: <code>-20</code></li>
+ * </ul>
+ * </li>
+ * <li><strong>Additive expression</strong>:
+ * <ul>
+ * <li>Expression type: [EMAIL PROTECTED] Expr#ARITHMETIC_EXPR}</li>
+ * <li>Operator type: [EMAIL PROTECTED]
OperatorExpr#PLUS_ADDITIVE} or [EMAIL PROTECTED]
OperatorExpr#MINUS_ADDITIVE}</li>
+ * <li>Example: <code>+20</code></li>
+ * </ul>
+ * </li>
+ * <li><strong>Multiplicative expression</strong>:
+ * <ul>
+ * <li>Expression type: [EMAIL PROTECTED] Expr#ARITHMETIC_EXPR}</li>
+ * <li>Operator type: [EMAIL PROTECTED] OperatorExpr#MULT_DIV} or
+ * [EMAIL PROTECTED] OperatorExpr#MULT_IDIV} or
+ * [EMAIL PROTECTED] OperatorExpr#MULT_MOD} or
+ * [EMAIL PROTECTED] OperatorExpr#MULT_PRODUCT}
</li>
+ * <li>Example: <code>10 * 20</code></li>
+ * </ul>
+ * </li>
+ * </ul>
+ * </li>
+ * <li><strong>Comparison expressions</strong>:
+ * <ul>
+ * <li>Expression type: [EMAIL PROTECTED] Expr#COMPARISON_EXPR}</li>
+ * <li>Operator type: XXX_COMPARISON</li>
+ * <li>Example: <code>$book1/author eq "Kennedy"</code></li>
+ * </ul>
+ * </li>
+ * <li><strong>Logical expressions</strong>:
+ * <ul>
+ * <li>Expression type: [EMAIL PROTECTED] Expr#LOGICAL_EXPR}</li>
+ * <li>Operator type: [EMAIL PROTECTED] OperatorExpr#AND_LOGICAL} or
+ * [EMAIL PROTECTED] OperatorExpr#OR_LOGICAL}</li>
+ * <li>Example: <code>1 eq 1 and 2 eq 2</code></li>
+ * </ul>
+ * </li>
+ * <li><strong>Path expressions</strong>: see [EMAIL PROTECTED]
PathExpr}</li>
* </ul>
* @see <a href="http://www.w3.org/TR/xpath20">XPath 2.0 Specification</href>
*/
public interface OperatorExpr extends Expr
{
- /**
- *
- */
+ /**
+ * <code>|</code> or <code>union</code>
+ */
short UNION_COMBINE = 0;
- /**
- *
- */
+ /**
+ * <code>intersect</code>
+ */
short INTERSECT_COMBINE = 1;
/**
- *
+ * <code>except</code>
*/
short EXCEPT_COMBINE = 2;
/**
- *
+ * <code>+</code>
*/
short PLUS_ADDITIVE = 3;
/**
- *
+ * <code>-</code>
*/
short MINUS_ADDITIVE = 4;
/**
- *
- */
- short RANGE = 5;
+ * <code>to</code>
+ */
+ short TO = 5;
/**
- *
- */
+ * <code>eq</code>
+ */
short EQUAL_VALUE_COMPARISON = 6;
/**
- *
- */
+ * <code>neq</code>
+ */
short NOTEQUAL_VALUE_COMPARISON = 7;
/**
- *
- */
+ * <code>lt</code>
+ */
short LESSTHAN_VALUE_COMPARISON = 8;
- /**
- *
- */
+ /**
+ * <code>le</code>
+ */
short LESSOREQUALTHAN_VALUE_COMPARISON = 9;
- /**
- *
- */
+ /**
+ * <code>gt</code>
+ */
short GREATTHAN_VALUE_COMPARISON = 10;
- /**
- *
- */
+ /**
+ * <code>ge</code>
+ */
short GREATOREQUALTHAN_VALUE_COMPARISON = 11;
- /**
- *
- */
- short EQUAL_GENERAL_COMPARISON = 12;
+ /**
+ * <code>=</code>
+ */
+ short EQUAL_GENERAL_COMPARISON = 12;
/**
- *
- */
+ * <code>!=</code>
+ */
short NOTEQUAL_GENERAL_COMPARISON = 13;
- /**
- *
- */
+ /**
+ * <code><</code>
+ */
short LESSTHAN_GENERAL_COMPARISON = 14;
/**
- *
- */
+ * <code><=</code>
+ */
short LESSOREQUALTHAN_GENERAL_COMPARISON = 15;
/**
- *
- */
+ * <code>></code>
+ */
short GREATTHAN_GENERAL_COMPARISON = 16;
/**
- *
- */
+ * <code>>=</code>
+ */
short GREATOREQUALTHAN_GENERAL_COMPARISON = 17;
/**
- *
- */
+ * <code>is</code>
+ */
short IS_NODE_COMPARISON = 18;
/**
- *
- */
+ * <code>isnot</code>
+ */
short ISNOT_NODE_COMPARISON = 19;
/**
- *
- */
+ * <code><</code>
+ */
short EARLIERTHAN_ORDER_COMPARISON = 20;
/**
- *
- */
+ * <code>>></code>
+ */
short LATERTHAN_ORDER_COMPARISON = 21;
/**
- *
- */
+ * <code>and</code>
+ */
short AND_LOGICAL = 22;
/**
- *
- */
+ * <code>or</code>
+ */
short OR_LOGICAL = 23;
/**
- *
- */
+ * <code>+ expr</code>
+ */
short PLUS_UNARY = 24;
/**
- *
- */
+ * <code>- expr</code>
+ */
short MINUS_UNARY = 25;
/**
- *
- */
+ * <code>/</code>
+ */
short SLASH_STEP = 26;
/**
- *
- */
- short SLASHSLASH_STEP = 27;
-
- /**
- *
- */
+ * <code>,</code>
+ */
short COMMA = 28;
/**
- *
- */
+ * <code>*</code>
+ */
short MULT_PRODUCT = 29;
/**
- *
- */
+ * <code>div</code>
+ */
short MULT_DIV = 30;
/**
- *
- */
+ * <code>idiv</code>
+ */
short MULT_IDIV = 31;
/**
- *
- */
+ * <code>mod</code>
+ */
short MULT_MOD = 32;
/**
* Gets the operator type
- * @return
+ * @return One one the operator type constants defined in this class
*/
short getOperatorType();
/**
* Gets the operand at the ith position.
+ * @throws IndexOutOfBoundsException
*/
Expr getOperand(int i);
@@ -255,7 +311,7 @@
int getOperandCount();
/**
- * Append an operand
+ * Append an operand at the end of this expression.
*/
void addOperand(Expr operand) throws XPathException;
@@ -265,9 +321,11 @@
void removeOperand(Expr operand) throws XPathException;
/**
- * Append the specified expr to the end of this expression. <br>
+ * Append the specified expr at the end of this expression.
* The specified expression has to be of the same type of this
expression,
- * otherwise an exception will be raised
+ * otherwise an exception will be raised.
+ * <p>For example, the result of appending <code>c/d</code>
+ * in the expression <code>a/b</code> is <code>a/b/c/d</code></p>
* @param expr The expression to append
*/
void append(OperatorExpr expr) throws XPathException;
1.1.2.5 +1 -19
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.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- Expr.java 12 Jul 2003 23:26:34 -0000 1.1.2.4
+++ Expr.java 14 Jul 2003 18:28:38 -0000 1.1.2.5
@@ -106,10 +106,6 @@
* <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>
@@ -122,10 +118,6 @@
* <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>
@@ -243,11 +235,6 @@
static final short SEQUENCE_EXPR = 7;
/**
- * The expression is a combine expression (union and intersection)
- */
- static final short COMBINE_EXPR = 8;
-
- /**
* The expression is a validate expression
*/
static final short VALIDATE_EXPR = 10;
@@ -266,11 +253,6 @@
* The expression is a variable reference
*/
static final short VARIABLE_REF_EXPR = 15;
-
- /**
- * The expression is a range expression
- */
- static final short RANGE_EXPR = 16;
/**
* The expression is a step
No revision
No revision
1.1.2.3 +30 -27
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.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- XPathUtilities.java 14 Jul 2003 15:38:17 -0000 1.1.2.2
+++ XPathUtilities.java 14 Jul 2003 18:28:38 -0000 1.1.2.3
@@ -89,12 +89,31 @@
{
case Expr.SEQUENCE_EXPR :
OperatorExpr op = (OperatorExpr) expr;
- if (op.getOperandCount() == 1)
+ switch (op.getOperatorType())
{
- result =
isMatchDocumentNode(op.getOperand(0));
- } else
- {
- result = false;
+ case OperatorExpr.COMMA :
+
+ if (op.getOperandCount() == 1)
+ {
+ result =
isMatchDocumentNode(op.getOperand(0));
+ } else
+ {
+ result = false;
+ }
+ break;
+ case OperatorExpr.UNION_COMBINE :
+ result = false;
+ for (int i =
op.getOperandCount() - 1; i >= 0; i--)
+ {
+ if
(isMatchDocumentNode(op.getOperand(i)))
+ {
+ result = true;
+ break;
+ }
+ }
+ break;
+ default :
+ result = false;
}
break;
case Expr.PATH_EXPR :
@@ -103,39 +122,23 @@
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;
+ 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;
- // Only union is valid in pattern
- if (c.getOperatorType() ==
OperatorExpr.UNION_COMBINE)
- {
- result = false;
- for (int i = c.getOperandCount() - 1; i
>= 0; i--)
- {
- if
(isMatchDocumentNode(c.getOperand(i)))
- {
- result = true;
- break;
- }
- }
- } else
- {
- result = false;
- }
default :
result = false;
}
No revision
No revision
1.1.2.9 +3 -20
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/test/Attic/TestSamples.xml
Index: TestSamples.xml
===================================================================
RCS file:
/home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/test/Attic/TestSamples.xml,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- TestSamples.xml 31 Mar 2003 23:05:53 -0000 1.1.2.8
+++ TestSamples.xml 14 Jul 2003 18:28:39 -0000 1.1.2.9
@@ -743,7 +743,7 @@
<!-- Range expr -->
- <expr value="1 to 100">
+ <expr value="(1 to 100)">
<ast>
<node name="ExprSequence">
<node name="RangeExpr">
@@ -754,25 +754,6 @@
</ast>
</expr>
- <expr value="(1 to 100)[(5 mod 5) eq 0]">
- <ast>
- <node name="ExprSequence">
- <node name="StepExpr">
- <node name="RangeExpr">
- <node name="IntegerLiteral"/>
- <node name="IntegerLiteral"/>
- </node>
- <node name="ComparisonExpr">
- <node name="MultiplicativeExpr">
- <node
name="IntegerLiteral"/>
- <node
name="IntegerLiteral"/>
- </node>
- <node name="IntegerLiteral"/>
- </node>
- </node>
- </node>
- </ast>
- </expr>
<expr value="a<<b">
<ast>
@@ -1033,6 +1014,8 @@
<expr value="toto/(45+23)" valid="false"/>
<expr value="a/(b,c)/d" valid="false"/>
+ <expr value="(1 to 100)[(5 mod 5) eq 0]" valid="false"/>
+
<!-- Expressions for which no common AST has been decided yet -->
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]