out-xpath: expression is to be specified as actionData i.e. after „--“ as a single string
1.1 --- a/java/alt2xml-out-xpath/src/cz/frantovo/alt2xml/out/xpath/XPathAction.java Thu Sep 04 16:07:10 2014 +0200
1.2 +++ b/java/alt2xml-out-xpath/src/cz/frantovo/alt2xml/out/xpath/XPathAction.java Thu Sep 04 16:14:15 2014 +0200
1.3 @@ -44,21 +44,23 @@
1.4 XPathFactory xpf = XPathFactory.newInstance();
1.5 XPath xp = xpf.newXPath();
1.6
1.7 - // String expressionString = getActionContext().
1.8 - String expressionString = "1+1";
1.9 - expressionString = "//property[@name='ccc']";
1.10 + if (getActionContext().getActionData().size() == 1) {
1.11 + String expressionString = getActionContext().getActionData().get(0);
1.12
1.13 - try {
1.14 - XPathExpression xpe = xp.compile(expressionString);
1.15 + try {
1.16 + XPathExpression xpe = xp.compile(expressionString);
1.17
1.18 - String result = xpe.evaluate(domResult.getNode());
1.19 + String result = xpe.evaluate(domResult.getNode());
1.20
1.21 - try (PrintWriter out = new PrintWriter(getActionContext().getOutputStream())) {
1.22 - out.println(result);
1.23 + try (PrintWriter out = new PrintWriter(getActionContext().getOutputStream())) {
1.24 + out.println(result);
1.25 + }
1.26 +
1.27 + } catch (XPathExpressionException e) {
1.28 + throw new OutputActionException("Unable to compile or evaluate XPath: " + expressionString, e);
1.29 }
1.30 -
1.31 - } catch (XPathExpressionException e) {
1.32 - throw new OutputActionException("Unable to compile or evaluate XPath: " + expressionString, e);
1.33 + } else {
1.34 + throw new OutputActionException("Please specify the XPath expression as action data");
1.35 }
1.36 }
1.37 }