Example usage for org.jdom2.output Format setExpandEmptyElements

List of usage examples for org.jdom2.output Format setExpandEmptyElements

Introduction

In this page you can find the example usage for org.jdom2.output Format setExpandEmptyElements.

Prototype

public Format setExpandEmptyElements(boolean expandEmptyElements) 

Source Link

Document

This will set whether empty elements are expanded from <tagName/> to <tagName></tagName>.

Usage

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);
}