1 /*
2 * SPDX-License-Identifier: Apache-2.0
3 * See LICENSE file for details.
4 *
5 * Copyright 2025-2026 Hazendaz
6 * Copyright 2011-2025 Acegi Technology Pty Limited.
7 */
8 package au.com.acegi.xmlformat;
9
10 import org.dom4j.io.OutputFormat;
11
12 /**
13 * Extended DOM4J configuration.
14 * <ul>
15 * <li>Defaults to pretty print.
16 * <li>Adds an option to keep blank lines.
17 * </ul>
18 */
19 public class XmlOutputFormat extends OutputFormat {
20
21 private boolean keepBlankLines;
22
23 /**
24 * Instantiates a new xml output format.
25 */
26 public XmlOutputFormat() {
27 // same as pretty print
28 setIndentSize(2);
29 setNewlines(true);
30 setTrimText(true);
31 setPadText(true);
32 }
33
34 /**
35 * When set to true, preserves at most one blank line between tags, if it was alredy present in the input file.
36 * Defaults to <code>false</code>.
37 *
38 * @return Whether blank lines are preserved, or not.
39 */
40 public boolean isKeepBlankLines() {
41 return keepBlankLines;
42 }
43
44 /**
45 * When set to true, preserves at most one blank line between tags, if it was alredy present in the input file.
46 *
47 * @param keepBlankLines
48 * true to preserve at most one blank line, false to remove all blank lines.
49 */
50 public void setKeepBlankLines(final boolean keepBlankLines) {
51 this.keepBlankLines = keepBlankLines;
52 }
53 }