Author: sandygao
Date: Fri Aug 26 18:34:10 2011
New Revision: 1162200
URL: http://svn.apache.org/viewvc?rev=1162200&view=rev
Log:
1. Proper handling of constructor functions in CTA XPath. 2. Add support for
fn:not function.
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/XPath20.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/XPath20Parser.java
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/XPath20.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/XPath20.java?rev=1162200&r1=1162199&r2=1162200&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/XPath20.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/XPath20.java
Fri Aug 26 18:34:10 2011
@@ -424,13 +424,16 @@ class FunctionNode extends XPathSyntaxTr
private QName name;
private XPathSyntaxTreeNode child;
- public FunctionNode(QName name, XPathSyntaxTreeNode child) {
+ public FunctionNode(QName name, XPathSyntaxTreeNode child) throws
XPathException {
+ if (!"not".equals(name.localpart) ||
!"http://www.w3.org/2005/xpath-functions".equals(name.uri)) {
+ throw new XPathException("Only support fn:not function.");
+ }
this.name = name;
this.child = child;
}
- public boolean evaluate(QName element, XMLAttributes attributes,
NamespaceContext nsContext) {
- return false;
+ public boolean evaluate(QName element, XMLAttributes attributes,
NamespaceContext nsContext) throws Exception {
+ return !child.evaluate(element, attributes, nsContext);
}
public String getValue(QName element, XMLAttributes attributes) {
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/XPath20Parser.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/XPath20Parser.java?rev=1162200&r1=1162199&r2=1162200&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/XPath20Parser.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/XPath20Parser.java
Fri Aug 26 18:34:10 2011
@@ -158,10 +158,29 @@ public class XPath20Parser {
case NCNAME:
name = QName();
consumeToken(OPEN_PARAN);
- n1 = OrExpr();
+ if ("not".equals(name.localpart) &&
"http://www.w3.org/2005/xpath-functions".equals(name.uri)) {
+ n1 = OrExpr();
+ consumeToken(CLOSE_PARAN);
+ return new FunctionNode(name, n1);
+ }
+ n1 = SimpleValue();
consumeToken(CLOSE_PARAN);
- return new FunctionNode(name, n1);
-
+ n1 = new CastNode(n1, name);
+ switch ((nextTokenIndex == -1) ? nextToken() : nextTokenIndex) {
+ case SYMBOL_EQ:
+ case SYMBOL_NE:
+ case SYMBOL_LT:
+ case SYMBOL_GT:
+ case SYMBOL_LE:
+ case SYMBOL_GE:
+ comp = Comparator();
+ n2 = ValueExpr();
+ return new CompNode(comp, n1, n2);
+
+ default:
+ array1[2] = gen;
+ }
+ return n1;
case SYMBOL_AT:
case NUMERIC_LITERAL:
case STRING_LITERAL:
@@ -205,7 +224,7 @@ public class XPath20Parser {
default:
// TODO: better way to intern the strings
local = t1.image.intern();
- name = new QName("", local, local, null);
+ name = new QName(null, local, local, null);
array1[4] = gen;
}
return name;
@@ -244,6 +263,25 @@ public class XPath20Parser {
}
}
+ private XPathSyntaxTreeNode ValueExpr() throws XPathException {
+ switch ((nextTokenIndex == -1) ? nextToken() : nextTokenIndex) {
+ case NCNAME:
+ QName name = QName();
+ consumeToken(OPEN_PARAN);
+ XPathSyntaxTreeNode n1 = SimpleValue();
+ consumeToken(CLOSE_PARAN);
+ return new CastNode(n1, name);
+ case SYMBOL_AT:
+ case NUMERIC_LITERAL:
+ case STRING_LITERAL:
+ return CastExpr();
+ default:
+ array1[3] = gen;
+ consumeToken(-1);
+ throw new XPathException("c-general-xpath");
+ }
+ }
+
private XPathSyntaxTreeNode CastExpr() throws XPathException {
XPathSyntaxTreeNode n;
QName name;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]