Author: ate
Date: Tue Oct 28 00:58:37 2014
New Revision: 1634758
URL: http://svn.apache.org/r1634758
Log:
SCXML-214: Replace JAXP xpath expression evaluation with Commons JXPath
- drop not used/needed Data() function support for xpath language
Modified:
commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/XPathEvaluator.java
Modified:
commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/XPathEvaluator.java
URL:
http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/XPathEvaluator.java?rev=1634758&r1=1634757&r2=1634758&view=diff
==============================================================================
---
commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/XPathEvaluator.java
(original)
+++
commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/XPathEvaluator.java
Tue Oct 28 00:58:37 2014
@@ -18,7 +18,6 @@ package org.apache.commons.scxml2.env.xp
import java.io.Serializable;
import java.util.Map;
-import java.util.regex.Pattern;
import org.apache.commons.jxpath.ClassFunctions;
import org.apache.commons.jxpath.FunctionLibrary;
@@ -65,17 +64,12 @@ public class XPathEvaluator implements E
}
}
-
- /** Pattern for recognizing the Commons SCXML Data() builtin function. */
- private static final Pattern dataFct = Pattern.compile("Data\\(");
-
private static final JXPathContext jxpathRootContext =
JXPathContext.newContext(null);
static {
FunctionLibrary xpathFunctions = new FunctionLibrary();
- xpathFunctions.addFunctions(new ClassFunctions(XPathFunctions.class,
"cs"));
xpathFunctions.addFunctions(new ClassFunctions(XPathFunctions.class,
null));
- // default generic JXPath functions
+ // also restore default generic JXPath functions
xpathFunctions.addFunctions(new PackageFunctions("", null));
jxpathRootContext.setFunctions(xpathFunctions);
}
@@ -111,9 +105,8 @@ public class XPathEvaluator implements E
public Object eval(final Context ctx, final String expr)
throws SCXMLExpressionException {
JXPathContext context = getContext(ctx);
- String evalExpr = dataFct.matcher(expr).replaceFirst("DataNode(");
try {
- return context.getValue(evalExpr, String.class);
+ return context.getValue(expr, String.class);
} catch (JXPathException xee) {
throw new SCXMLExpressionException(xee.getMessage(), xee);
}
@@ -139,11 +132,9 @@ public class XPathEvaluator implements E
@Override
public Node evalLocation(final Context ctx, final String expr)
throws SCXMLExpressionException {
- String evalExpr = dataFct.matcher(expr).
- replaceFirst("DataNode(");
JXPathContext context = getContext(ctx);
try {
- return (Node)context.selectSingleNode(evalExpr);
+ return (Node)context.selectSingleNode(expr);
} catch (JXPathException xee) {
throw new SCXMLExpressionException(xee.getMessage(), xee);
}