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:ca.nrc.cadc.vosi.TableWriter.java

License:Open Source License

public void write(TableDesc table, Writer writer) throws IOException {
    TableSet tset = new TableSet(null);
    Document doc = tset.getTableDocument(table);
    XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
    out.output(doc, writer);//from   w  w w .  j  ava 2s  .c  o  m
}

From source file:cager.parser.test.SimpleTest2.java

License:Open Source License

private String elementoToString(Element segmento) {

    Document documentJDOM = new Document();
    documentJDOM.addContent(segmento);/*  w  w w.j  av  a2 s  .c om*/
    // Vamos a serializar el XML  
    // Lo primero es obtener el formato de salida  
    // Partimos del "Formato bonito", aunque tambin existe el plano y el compacto  
    Format format = Format.getPrettyFormat();
    // Creamos el serializador con el formato deseado  
    XMLOutputter xmloutputter = new XMLOutputter(format);
    // Serializamos el document parseado  
    String docStr = xmloutputter.outputString(documentJDOM);

    FileOutputStream fout;
    try {
        fout = new FileOutputStream(ruta + "VBParser\\ejemplosKDM\\archivo.kdm");
        //fout = new FileOutputStream("E:\\WorkspaceParser\\VBParser\\ejemplosKDM\\archivo.kdm");
        xmloutputter.output(documentJDOM, fout);
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return docStr;
}

From source file:cager.parser.test.SimpleTest3.java

License:Open Source License

private String elementoToString(Element segmento) {

    Document documentJDOM = new Document();
    documentJDOM.addContent(segmento);//from  ww  w .  j  av a  2 s .  c  om
    // Vamos a serializar el XML  
    // Lo primero es obtener el formato de salida  
    // Partimos del "Formato bonito", aunque tambin existe el plano y el compacto  
    Format format = Format.getPrettyFormat();
    // Creamos el serializador con el formato deseado  
    XMLOutputter xmloutputter = new XMLOutputter(format);
    // Serializamos el document parseado  
    String docStr = xmloutputter.outputString(documentJDOM);

    FileOutputStream fout;
    try {
        fout = new FileOutputStream(ruta + "VBParser\\ejemplosKDM\\archivo.kdm");
        //fout = new FileOutputStream("E:\\WorkspaceParser\\VBParser\\ejemplosKDM\\archivo.kdm");
        xmloutputter.output(documentJDOM, fout);
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return docStr;
}

From source file:carb.view.ParsingEverything.java

static void affiche() {
    try {//  w ww.j a v a2 s .  c  o  m
        //On utilise ici un affichage classique avec getPrettyFormat()
        XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
        sortie.output(document, System.out);
    } catch (java.io.IOException e) {
    }
}

From source file:carb.view.ParsingEverything.java

static void enregistre(String fichier) {
    try {//from  w  w  w. java 2s.c  om
        //On utilise ici un affichage classique avec getPrettyFormat()
        XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
        //Remarquez qu'il suffit simplement de crer une instance de FileOutputStream
        //avec en argument le nom du fichier pour effectuer la srialisation.
        sortie.output(document, new FileOutputStream(fichier));
    } catch (java.io.IOException e) {
    }
}

From source file:ch.ledcom.maven.sitespeed.utils.XmlPrettyPrinter.java

License:Apache License

public static void prettyPrint(Document doc, OutputStream out) throws IOException {
    new XMLOutputter(Format.getPrettyFormat()).output(doc, out);
}

From source file:com.archimatetool.jdom.JDOMUtils.java

License:Open Source License

/**
 * Writes a JDOM Document to file//from   w  ww . jav a  2 s.  c o  m
 * @param doc The JDOM Document to write
 * @param file The file to write to
 * @throws IOException
 */
public static void write2XMLFile(Document doc, File file) throws IOException {
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());

    // Create parent folder if it doesn't exist
    File parent = file.getParentFile();
    if (parent != null) {
        parent.mkdirs();
    }

    FileOutputStream out = new FileOutputStream(file);
    outputter.output(doc, out);
    out.close();
}

From source file:com.archimatetool.jdom.JDOMUtils.java

License:Open Source License

/**
 * Convert a JDOM Document to a String format
 * @param doc The JDOM Document/*from  www. j  ava2s .c o  m*/
 * @return The resulting String
 * @throws IOException
 */
public static String write2XMLString(Document doc) throws IOException {
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());

    StringWriter out = new StringWriter();
    outputter.output(doc, out);
    out.close();

    return out.toString();
}

From source file:com.bennavetta.util.tycho.impl.DefaultWrapperGenerator.java

License:Apache License

private void writeModules(List<String> modules, File pomFile) throws JDOMException, IOException {
    SAXBuilder builder = new SAXBuilder();
    Document pom = builder.build(pomFile);
    Namespace pomNs = pom.getRootElement().getNamespace();
    Element modulesElem = pom.getRootElement().getChild("modules", pomNs);
    if (modulesElem == null) {
        modulesElem = new Element("modules", pomNs);
        pom.getRootElement().addContent(modulesElem);
    }/*from w ww . j  a  v  a2 s .  com*/
    for (String module : modules) {
        boolean exists = false;
        for (Element existingModule : modulesElem.getChildren()) {
            if (existingModule.getTextTrim().equals(module)) {

                exists = true;
                break;
            }
        }
        if (!exists) {
            Element moduleElem = new Element("module", pomNs);
            moduleElem.setText(module);
            modulesElem.addContent(moduleElem);
        }
    }
    XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat().setIndent("\t"));
    try (FileOutputStream out = new FileOutputStream(pomFile)) {
        xout.output(pom, out);
    }
}

From source file:com.c4om.autoconf.ulysses.extra.svrlmultipathinterpreter.SVRLMultipathInterpreterMain.java

License:Apache License

/**
 * Main method, invoked when the application starts
 * @param args command-line arguments. First is path to svrl document, second is the path to the configuration, third is the path to the metamodel
 *//*  w  ww  . j  a  v  a2  s  . c  o m*/
public static void main(String[] args) throws Exception {
    SVRLMultipathInterpreterMain multipathInterpreter = new SVRLMultipathInterpreterMain(args[1], args[2],
            args[3]);
    Document svrlDocument = loadJDOMDocumentFromFile(new File(args[0]));
    Document result = multipathInterpreter.interpret(svrlDocument);
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
    System.out.println(outputter.outputString(result));
}