List of usage examples for org.jdom2.output Format setExpandEmptyElements
public Format setExpandEmptyElements(boolean expandEmptyElements)
<tagName/>
to <tagName></tagName>
. From source file:nl.colorize.util.xml.XMLHelper.java
License:Apache License
private static XMLOutputter getOutputter() { Format formatter = Format.getPrettyFormat(); formatter.setEncoding(Charsets.UTF_8.displayName()); formatter.setIndent(" "); formatter.setLineSeparator(Platform.getLineSeparator()); formatter.setExpandEmptyElements(false); formatter.setOmitDeclaration(false); formatter.setOmitEncoding(false);/* w ww . j a v a2s .c o m*/ XMLOutputter outputter = new XMLOutputter(formatter); outputter.setFormat(formatter); return outputter; }
From source file:org.polago.deployconf.DeploymentWriter.java
License:Open Source License
/** * Write the given DeploymentConfig to persistent storage. * * @param deploymentConfig the DeploymentConfig to persist * @throws IOException indicating IO problems *//*from w w w . jav a 2s . c om*/ public void persist(DeploymentConfig deploymentConfig) throws IOException { Format format = Format.getPrettyFormat(); format.setLineSeparator(LineSeparator.UNIX); format.setExpandEmptyElements(true); XMLOutputter outputter = new XMLOutputter(format); Element root = new Element(DOM_ROOT); String name = deploymentConfig.getName(); if (name != null) { root.setAttribute(ATTR_NAME, name); } Document document = new Document(); document.setRootElement(root); for (Task task : deploymentConfig.getTasks()) { Element node = new Element(task.getSerializedName()); root.addContent(node); task.serialize(node, groupManager); } outputter.output(document, outputStream); }