# HG changeset patch
# User František Kučera <franta-hg@frantovo.cz>
# Date 1410021444 -7200
# Node ID 3581fe8cd4feb075a78948ef8470b44614b6da48
# Parent  afcb4ccc6594711c8beff63d1017a6e09d1bcca2
out-xpath: trailing line-break is optional

diff -r afcb4ccc6594 -r 3581fe8cd4fe 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	Sat Sep 06 18:29:44 2014 +0200
+++ b/java/alt2xml-out-xpath/src/cz/frantovo/alt2xml/out/xpath/XPathAction.java	Sat Sep 06 18:37:24 2014 +0200
@@ -38,6 +38,9 @@
 public class XPathAction extends AbstractDOMAction {
 
 	public static final String PARAMETER_TYPED_PARAMETERS = "typed-parameters";
+	public static final String PARAMETER_LINE_BREAK = "line-break";
+	private final boolean typedParameters;
+	private final boolean lineBreak;
 	private final XPathFactory xpathFactory;
 	private final XPath xpath;
 	private final String expressionString;
@@ -54,7 +57,8 @@
 			throw new OutputActionException("Please specify the XPath expression as action data");
 		} else {
 
-			boolean typedParameters = Boolean.parseBoolean(actionContext.getActionProperties().getProperty(PARAMETER_TYPED_PARAMETERS));
+			typedParameters = Boolean.parseBoolean(actionContext.getActionProperties().getProperty(PARAMETER_TYPED_PARAMETERS));
+			lineBreak = Boolean.parseBoolean(actionContext.getActionProperties().getProperty(PARAMETER_LINE_BREAK, Boolean.TRUE.toString()));
 
 			Map<String, Object> xpathParameters = new HashMap<>();
 
@@ -139,7 +143,10 @@
 		try {
 			String result = xpathExpression.evaluate(domResult.getNode());
 			try (PrintWriter out = new PrintWriter(getActionContext().getOutputStream())) {
-				out.println(result);
+				out.print(result);
+				if (lineBreak) {
+					out.println();
+				}
 			}
 		} catch (XPathExpressionException e) {
 			throw new OutputActionException("Unable to evaluate XPath: " + xpathExpression, e);