# HG changeset patch # User František Kučera # Date 1409840055 -7200 # Node ID 5c4ae2ed5d97de714b7ee6315c53ce15b0574ff6 # Parent e2c691eedf4d62d6df4cb8e74daa754e287a8c04 out-xpath: expression is to be specified as actionData i.e. after „--“ as a single string diff -r e2c691eedf4d -r 5c4ae2ed5d97 java/alt2xml-out-xpath/src/cz/frantovo/alt2xml/out/xpath/XPathAction.java --- a/java/alt2xml-out-xpath/src/cz/frantovo/alt2xml/out/xpath/XPathAction.java Thu Sep 04 16:07:10 2014 +0200 +++ b/java/alt2xml-out-xpath/src/cz/frantovo/alt2xml/out/xpath/XPathAction.java Thu Sep 04 16:14:15 2014 +0200 @@ -44,21 +44,23 @@ XPathFactory xpf = XPathFactory.newInstance(); XPath xp = xpf.newXPath(); - // String expressionString = getActionContext(). - String expressionString = "1+1"; - expressionString = "//property[@name='ccc']"; + if (getActionContext().getActionData().size() == 1) { + String expressionString = getActionContext().getActionData().get(0); - try { - XPathExpression xpe = xp.compile(expressionString); + try { + XPathExpression xpe = xp.compile(expressionString); - String result = xpe.evaluate(domResult.getNode()); + String result = xpe.evaluate(domResult.getNode()); - try (PrintWriter out = new PrintWriter(getActionContext().getOutputStream())) { - out.println(result); + try (PrintWriter out = new PrintWriter(getActionContext().getOutputStream())) { + out.println(result); + } + + } catch (XPathExpressionException e) { + throw new OutputActionException("Unable to compile or evaluate XPath: " + expressionString, e); } - - } catch (XPathExpressionException e) { - throw new OutputActionException("Unable to compile or evaluate XPath: " + expressionString, e); + } else { + throw new OutputActionException("Please specify the XPath expression as action data"); } } }