villard 2003/07/25 13:16:26
Modified: java/xpath_rwapi/src2/org/apache/xpath/impl Tag: xslt20
ExpressionFactoryImpl.java NameTestImpl.java
java/xpath_rwapi/src2/org/apache/xpath/expression Tag:
xslt20 StaticContext.java ExpressionFactory.java
java/xpath_rwapi/src2/org/apache/xpath/impl/parser Tag:
xslt20 SimpleNode.java QNameWrapper.java
java/xpath_rwapi/src2/org/apache/xpath/test Tag: xslt20
TestSamples.java TestSamples.xml
Removed: java/xpath_rwapi/src2/org/apache/xpath/impl Tag: xslt20
ExprContextImpl.java
java/xpath_rwapi/src2/org/apache/xpath/expression Tag:
xslt20 ExprContext.java
Log:
javadoc + cleanup expression factory
added createExpr(StaticContext, String)
added createQName(ns, localpart, prefix)
Revision Changes Path
No revision
No revision
1.1.2.9 +18 -32
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.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- ExpressionFactoryImpl.java 14 Jul 2003 18:28:38 -0000 1.1.2.8
+++ ExpressionFactoryImpl.java 25 Jul 2003 20:16:25 -0000 1.1.2.9
@@ -72,38 +72,19 @@
import org.apache.xpath.expression.NodeTest;
import org.apache.xpath.expression.OperatorExpr;
import org.apache.xpath.expression.PathExpr;
+import org.apache.xpath.expression.StaticContext;
import org.apache.xpath.expression.StepExpr;
-import org.apache.xpath.impl.parser.NodeFactory;
import org.apache.xpath.impl.parser.ParseException;
import org.apache.xpath.impl.parser.XPath;
import org.apache.xpath.impl.parser.XPathTreeConstants;
/**
* Default implementation expression factory to create XPath AST nodes.
- * //@TODO not fully implemented! 13-Mar-03 -sc
*/
public class ExpressionFactoryImpl implements ExpressionFactory {
- /**
- * Node factory
- */
- protected NodeFactory m_nodeFactory = null;
-
- /* (non-Javadoc)
- * @see
org.apache.xpath.expression.ExpressionFactory#setNodeFactory(org.apache.xpath.impl.parser.NodeFactory)
- */
- public void setNodeFactory(NodeFactory factory) {
- m_nodeFactory = factory;
- }
-
- /**
- * @see
org.apache.xpath.expression.ExpressionFactory#createExpr(java.lang.String)
- */
public Expr createExpr(String expr) throws XPathException {
XPath parser = new XPath(new StringReader(expr));
- if ( m_nodeFactory != null ) {
- parser.setNodeFactory(m_nodeFactory);
- }
try {
return (Expr) parser.XPath2().jjtGetChild(0);
} catch (ParseException e) {
@@ -111,6 +92,17 @@
}
}
+ public Expr createExpr(StaticContext ctx, String expr)
+ throws XPathException
+ {
+ XPath parser = new XPath(new StringReader(expr));
+ try {
+ return (Expr) parser.XPath2().jjtGetChild(0);
+ } catch (ParseException e) {
+ throw new XPathException(e);
+ }
+ }
+
/**
* @see
org.apache.xpath.expression.ExpressionFactory#createPathExpr(boolean)
*/
@@ -130,8 +122,8 @@
/**
* @see
org.apache.xpath.expression.ExpressionFactory#createNameTest(java.lang.String,
java.lang.String)
*/
- public NodeTest createNameTest(String namespace, String name) {
- return new NameTestImpl(namespace, name);
+ public NodeTest createNameTest(QName qname) {
+ return new NameTestImpl(qname);
}
/**
@@ -234,31 +226,21 @@
}
- /**
- * @see
org.apache.xpath.expression.ExpressionFactory#createStringLiteralExpr(java.lang.String)
- */
public Literal createStringLiteralExpr(String value) {
LiteralImpl lit = new LiteralImpl();
lit.setStringValue(value);
return lit;
}
- /**
- * @see
org.apache.xpath.expression.ExpressionFactory#createDoubleLiteralExpr(double)
- */
public Literal createDoubleLiteralExpr(double value) {
LiteralImpl lit = new LiteralImpl();
lit.setDoubleValue(value);
return lit;
}
- /* (non-Javadoc)
- * @see org.apache.xpath.expression.ExpressionFactory#createSequence()
- */
public OperatorExpr createSequence() {
return new OperatorImpl(XPathTreeConstants.JJTEXPRSEQUENCE);
}
-
public FunctionCall createFunctionCall(QName name)
{
@@ -266,5 +248,9 @@
}
+ public QName createQName(String ns, String localPart, String prefix)
+ {
+ return new QName(ns, localPart, prefix);
+ }
}
1.1.2.4 +2 -5
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/NameTestImpl.java
Index: NameTestImpl.java
===================================================================
RCS file:
/home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/NameTestImpl.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- NameTestImpl.java 28 Mar 2003 22:47:40 -0000 1.1.2.3
+++ NameTestImpl.java 25 Jul 2003 20:16:25 -0000 1.1.2.4
@@ -86,15 +86,12 @@
/**
* Constructor for NodeTestImpl. Internal uses only
- *
- * @param namespace DOCUMENT ME!
- * @param localpart DOCUMENT ME!
*/
- public NameTestImpl(String namespace, String localpart)
+ public NameTestImpl(QName qname)
{
super(XPathTreeConstants.JJTNAMETEST);
- m_qname = new QName(namespace, localpart);
+ m_qname = qname;
}
/**
No revision
No revision
1.1.2.2 +8 -5
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/StaticContext.java
Index: StaticContext.java
===================================================================
RCS file:
/home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/StaticContext.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- StaticContext.java 13 Mar 2003 20:28:17 -0000 1.1.2.1
+++ StaticContext.java 25 Jul 2003 20:16:26 -0000 1.1.2.2
@@ -60,7 +60,7 @@
import org.apache.xml.NamespaceContext;
/**
- * Represents the static context of an expression.
+ * Static context of expression.
* @see <a href="http://www.w3.org/TR/xpath20/#static_context">XPath 2.0
specification</a>
*/
public interface StaticContext {
@@ -69,22 +69,25 @@
short FLEXIBLE_POLICY = 1;
/**
- * One of STRICT_POLICY or FLEXIBLE_POLICY
+ * Gets the exception policy to apply.
+ * @return short [EMAIL PROTECTED] #STRICT_POLICY} or [EMAIL PROTECTED]
#FLEXIBLE_POLICY}
*/
short getExceptionPolicy();
/**
- * In-scope namespaces. This is a set of (prefix, URI) pairs.
+ * Gets in-scope namespaces.
*/
NamespaceContext getNamespaces();
/**
- * Default namespace for element and type names.
+ * Gets the default namespace for element and type names.
+ * @return namespace
*/
String getDefaultNamepaceForElement();
/**
- * Default namespace for function names.
+ * Gets the default namespace for function names.
+ * @return namespace
*/
String getDefaultNamepaceforFunction();
1.1.2.9 +34 -12
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.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- ExpressionFactory.java 12 Jul 2003 23:52:50 -0000 1.1.2.8
+++ ExpressionFactory.java 25 Jul 2003 20:16:26 -0000 1.1.2.9
@@ -55,13 +55,12 @@
*/
package org.apache.xpath.expression;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
import org.apache.xml.QName;
import org.apache.xpath.XPathException;
import org.apache.xpath.datamodel.SequenceType;
-import org.apache.xpath.impl.parser.NodeFactory;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
/**
@@ -75,11 +74,26 @@
public interface ExpressionFactory
{
/**
- * Creates a new XPath expression from a string representation
+ * Creates a new XPath/XQuery expression from a string representation.
+ * <p>For XPath expression, default element and function namespace are
+ * used to resolve prefixes.
+ * Moreover, various checking are not performed, like the existence test
+ * of variable declaration</p>
* @return A XPath expression
- * @throws XPathException whenever the specified expression is not valid
syntaxically or semantically.
+ * @throws XPathException whenever the specified expression is not valid
+ * syntaxically or semantically.
*/
public Expr createExpr(String expr) throws XPathException;
+
+ /**
+ * Creates a new XPath expression from a string representation.
+ * Use the specified static context to resolve namespaces and perform
+ * various static type checking.
+ * @return A XPath expression
+ * @throws XPathException whenever the specified expression is not
valid
+ * syntaxically or semantically.
+ */
+ public Expr createExpr(StaticContext ctx, String expr) throws
XPathException;
/**
* Creates a new empty [EMAIL PROTECTED] OperatorExpr expression
sequence}
@@ -104,7 +118,7 @@
* Creates a name test.
* @return A name test
*/
- public NodeTest createNameTest(String namespace, String name);
+ public NodeTest createNameTest(QName qname);
/**
* Creates a new [EMAIL PROTECTED] OperatorExpr combining expression} of
the specified type
@@ -226,9 +240,17 @@
* @return
*/
public FunctionCall createFunctionCall(QName name);
+
+
+ /**
+ * Creates a [EMAIL PROTECTED] QName qname} with the specified prefix,
namespace
+ * and local part.
+ * @param ns or null
+ * @param localPart
+ * @param prefix or null
+ * @return
+ */
+ public QName createQName(String ns, String localPart, String prefix);
- /**
- * Sets the node factory to use for creating AST nodes
- */
- void setNodeFactory(NodeFactory factory);
+
}
No revision
No revision
1.1.2.11 +1 -0
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/parser/Attic/SimpleNode.java
Index: SimpleNode.java
===================================================================
RCS file:
/home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/parser/Attic/SimpleNode.java,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -u -r1.1.2.10 -r1.1.2.11
--- SimpleNode.java 24 Jun 2003 21:09:08 -0000 1.1.2.10
+++ SimpleNode.java 25 Jul 2003 20:16:26 -0000 1.1.2.11
@@ -23,6 +23,7 @@
public class SimpleNode implements Node
{
public static boolean PRODUCE_RAW_TREE = false;
+
final static private NodeFactory DEFAULT_NODE_FACTORY = new
DefaultNodeFactory();
/**
1.1.2.4 +1 -1
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/parser/Attic/QNameWrapper.java
Index: QNameWrapper.java
===================================================================
RCS file:
/home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/parser/Attic/QNameWrapper.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- QNameWrapper.java 28 Mar 2003 22:47:41 -0000 1.1.2.3
+++ QNameWrapper.java 25 Jul 2003 20:16:26 -0000 1.1.2.4
@@ -115,7 +115,7 @@
if ( colonIdx == -1 ) {
m_qname = new QName(qname);
} else {
- // TODO: Need a prefix resolver
+ // TODO: Need to use qname factory
m_qname = new QName("defaultns", qname.substring(colonIdx +
1), qname.substring(0, colonIdx ) );
}
break;
No revision
No revision
1.1.2.10 +2 -2
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/test/Attic/TestSamples.java
Index: TestSamples.java
===================================================================
RCS file:
/home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/test/Attic/TestSamples.java,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -r1.1.2.9 -r1.1.2.10
--- TestSamples.java 11 Jul 2003 19:09:26 -0000 1.1.2.9
+++ TestSamples.java 25 Jul 2003 20:16:26 -0000 1.1.2.10
@@ -142,12 +142,12 @@
PathExpr pathExpr = exprFct.createPathExpr(true);
System.out.println("/ =? " + pathExpr.getString(true));
- NodeTest nt = exprFct.createNameTest(null, "toto");
+ NodeTest nt = exprFct.createNameTest(null);
pathExpr.addOperand(exprFct.createStepExpr(StepExpr.AXIS_CHILD,
nt));
System.out.println("/toto =? " + pathExpr.getString(true));
System.out.println("/child::toto =? " +
pathExpr.getString(false));
- nt = exprFct.createNameTest(null, "titi");
+ nt = exprFct.createNameTest(null);
pathExpr.addOperand(exprFct.createStepExpr(
StepExpr.AXIS_DESCENDANT, nt));
1.1.2.10 +3 -1
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.9
retrieving revision 1.1.2.10
diff -u -r1.1.2.9 -r1.1.2.10
--- TestSamples.xml 14 Jul 2003 18:28:39 -0000 1.1.2.9
+++ TestSamples.xml 25 Jul 2003 20:16:26 -0000 1.1.2.10
@@ -887,6 +887,8 @@
<!-- Constructor functions -->
+ <expr value="(1 to 100)[(5 mod 5) eq 0]" valid="false"/>
+
<expr value="xs:date('2000-01-01')">
<ast>
<node name="ExprSequence">
@@ -1014,7 +1016,7 @@
<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]