Example usage for org.jdom2.output XMLOutputter XMLOutputter

List of usage examples for org.jdom2.output XMLOutputter XMLOutputter

Introduction

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

Prototype

public XMLOutputter(XMLOutputProcessor processor) 

Source Link

Document

This will create an XMLOutputter with the specified XMLOutputProcessor.

Usage

From source file:io.wcm.handler.richtext.RichText.java

License:Apache License

/**
 * @return Formatted markup/*w w w.  j  a  v a2s . c  o  m*/
 */
public String getMarkup() {
    if (!isValid()) {
        return null;
    }
    return new XMLOutputter(JDOM_FORMAT).outputString(this.content);
}

From source file:io.wcm.maven.plugins.contentpackage.unpacker.ContentUnpacker.java

License:Apache License

private void writeXmlWithExcludes(InputStream inputStream, OutputStream outputStream)
        throws IOException, JDOMException {
    SAXBuilder saxBuilder = new SAXBuilder();
    Document doc = saxBuilder.build(inputStream);
    applyXmlExcludes(doc.getRootElement(), "");

    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat().setLineSeparator(LineSeparator.UNIX));
    outputter.setXMLOutputProcessor(new OneAttributePerLineXmlProcessor());
    outputter.output(doc, outputStream);
    outputStream.flush();//  w w  w  .  ja v  a 2 s  . c  om
}

From source file:io.wcm.maven.plugins.i18n.SlingI18nMap.java

License:Apache License

/**
 * Build i18n resource XML in Sling i18n Message format.
 * @return XML//w  ww.  jav  a  2 s .com
 */
public String getI18nXmlString() {
    Format format = Format.getPrettyFormat();
    XMLOutputter outputter = new XMLOutputter(format);
    return outputter.outputString(buildI18nXml());
}

From source file:it.cnr.ilc.clavius.controller.ProofReaderController.java

public void saveProof() {
    System.err.println("salva proofreader.." + getCurrSentenceNumber());

    Document analysis = this.getDocumentTei().getAnalysis();

    Element rootNode = analysis.getRootElement();
    List<Element> sentenceList = rootNode.getChildren("sentence");
    Element sentenceNode = sentenceList.get(getCurrSentenceNumber().intValue());
    List<Element> tokenList = sentenceNode.getChildren("token");

    for (int i = 0; i < tokenList.size(); i++) {
        Element tokenNode = (Element) tokenList.get(i);
        PosTaggedToken tk = res.get(i);// www . j a v a2  s . c  o m
        tokenNode.setAttribute("lemma", tk.getLemma());
        tokenNode.setAttribute("morphoCode",
                tk.getPosTag().get(0).concat(tk.getPerson().get(0)).concat(tk.getNumber().get(0))
                        .concat(tk.getTense().get(0)).concat(tk.getMood().get(0)).concat(tk.getVoice().get(0))
                        .concat(tk.getGender().get(0)).concat(tk.getCases().get(0))
                        .concat(tk.getDegree().get(0))

        );
    }

    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
    String newAnalysis = outputter.outputString(analysis);
    StringBuilder sb = new StringBuilder(newAnalysis);

    HelperIO.writeOut(sb,
            HandleConstants.getWorkDir().concat(HandleConstants.getLetterRif()).concat("-linguistic-dev.xml"));

}

From source file:it.cnr.ilc.clavius.controller.TranscriptionController.java

public String getTemplate() {
    Document doc = transcriptionManager.getDocTemplate(sentence.getLetterIdentificator());
    XMLOutputter xop = new XMLOutputter(Format.getPrettyFormat());
    template = xop.outputString(doc);//from  w ww. ja  v  a 2s . co  m
    return template;

}

From source file:it.cnr.ilc.clavius.controller.TranscriptionController.java

public String getTeiDoc() throws Exception {
    Document doc = transcriptionManager.getDoc(getDocid());
    XMLOutputter xop = new XMLOutputter(Format.getPrettyFormat());
    teiDoc = xop.outputString(doc);//from w  w w.j a v  a  2 s . c  o  m
    return teiDoc;
}

From source file:it.cnr.ilc.clavius.manager.action.HelperIO.java

public static void fromDomToFile(Document doc, String filePath) {
    System.err.println("in fromDomToFile");
    try {/*  w w w.j  a va  2 s . c o  m*/
        File parent = new File(filePath).getParentFile();
        parent.mkdirs();
        XMLOutputter xo = new XMLOutputter(Format.getPrettyFormat());
        xo.output(doc, new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filePath), "UTF-8")));
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:jcodecollector.io.PackageManager.java

License:Apache License

public static boolean exportSnippets(File file, String category) {
    ArrayList<Snippet> array = null;

    if (category == null) {
        array = DBMS.getInstance().getAllSnippets();
    } else {// ww  w.  j  a v a 2 s  .com
        array = DBMS.getInstance().getSnippets(category);
    }

    Element root = new Element("jcc-snippets-package");
    root.setAttribute("version", GeneralInfo.APPLICATION_VERSION);

    Iterator<Snippet> iterator = array.iterator();
    while (iterator.hasNext()) {
        Snippet snippet = iterator.next();
        Element element = new Element("snippet");

        Element category_xml = new Element("category");
        category_xml.setText(snippet.getCategory());
        element.addContent(category_xml);

        Element name_xml = new Element("name");
        name_xml.setText(snippet.getName());
        element.addContent(name_xml);

        String[] tags = snippet.getTags();
        for (String tag : tags) {
            Element tag_xml = new Element("tag");
            tag_xml.setText(tag);
            element.addContent(tag_xml);
        }

        Element syntax_xml = new Element("syntax");
        syntax_xml.setText(snippet.getSyntax());
        element.addContent(syntax_xml);

        Element code_xml = new Element("code");
        code_xml.setText(snippet.getCode());
        element.addContent(code_xml);

        Element comment_xml = new Element("comment");
        comment_xml.setText(snippet.getComment());
        element.addContent(comment_xml);

        root.addContent(element);
    }

    try {
        XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
        outputter.output(new Document(root), new FileOutputStream(file));
        return true;
    } catch (Exception ex) {
        ex.printStackTrace();
        return false;
    }
}

From source file:jcodecollector.io.XMLManagerOldVersion.java

License:Apache License

public static boolean createPackage(File file, String name) {
    ArrayList<Snippet> array = DBMS.getInstance().getSnippets(name);
    Element root_xml = new Element("jcc-snippets-package");
    boolean success;

    Iterator<Snippet> iterator = array.iterator();
    while (iterator.hasNext()) {
        Snippet snippet = iterator.next();
        Element element = new Element("snippet");

        Element category_xml = new Element("category");
        category_xml.setText(snippet.getCategory());
        element.addContent(category_xml);

        Element name_xml = new Element("name");
        name_xml.setText(snippet.getName());
        element.addContent(name_xml);/*from   w w w  .j  a  v  a 2s  . c o  m*/

        String[] tags = snippet.getTags();
        for (String tag : tags) {
            Element tag_xml = new Element("tag");
            tag_xml.setText(tag);
            element.addContent(tag_xml);
        }

        Element syntax_xml = new Element("syntax");
        syntax_xml.setText(snippet.getSyntax());
        element.addContent(syntax_xml);

        Element code_xml = new Element("code");
        code_xml.setText(snippet.getCode());
        element.addContent(code_xml);

        Element comment_xml = new Element("comment");
        comment_xml.setText(snippet.getComment());
        element.addContent(comment_xml);

        Element locked_xml = new Element("locked");
        locked_xml.setText(String.valueOf(snippet.isLocked()));
        element.addContent(locked_xml);

        root_xml.addContent(element);
    }

    try {
        XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
        outputter.output(new Document(root_xml), new FileOutputStream(file));

        success = true;
    } catch (Exception ex) {
        ex.printStackTrace();
        success = false;
    }

    return success;
}

From source file:jetbrains.buildServer.tools.XmlUtil.java

License:Apache License

public static void saveDocument(@NotNull Document document, @NotNull OutputStream os) throws IOException {
    OutputStreamWriter writer = new OutputStreamWriter(os, Charset.forName("UTF-8"));

    try {/*from   w w  w.  j  a va2 s .  c  om*/
        final Format format = Format.getPrettyFormat();
        format.setLineSeparator(System.getProperty("line.separator"));
        format.setEncoding("UTF-8");
        new XMLOutputter(format).output(document, writer);
    } finally {
        writer.flush();
        writer.close();
    }
}