Search in sources :

Example 51 with XMLOutputter

use of org.jdom.output.XMLOutputter in project tdi-studio-se by Talend.

the class SOAPUtil method Doc2StringWithoutDeclare.

private String Doc2StringWithoutDeclare(Document doc) {
    DOMBuilder builder = new DOMBuilder();
    org.jdom.Document jdomDoc = builder.build(doc);
    XMLOutputter outputter = new XMLOutputter();
    return outputter.outputString(jdomDoc.getRootElement());
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) DOMBuilder(org.jdom.input.DOMBuilder)

Example 52 with XMLOutputter

use of org.jdom.output.XMLOutputter in project intellij-plugins by StepicOrg.

the class StudySerializationUtilsTest method before.

@BeforeClass
public static void before() {
    outputter = new XMLOutputter();
    Format format = Format.getPrettyFormat().setLineSeparator("\n");
    outputter.setFormat(format);
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format) BeforeClass(org.junit.BeforeClass)

Example 53 with XMLOutputter

use of org.jdom.output.XMLOutputter in project beast-mcmc by beast-dev.

the class XMLModelCombiner method writeXML.

public void writeXML(OutputStream ostream) {
    from.prefixIdentifiedNames("from", mapping.getFromNames(), true);
    to.prefixIdentifiedNames("to", mapping.getToNames(), false);
    XMLOutputter outputter = new XMLOutputter();
    from.print(outputter, ostream);
    to.print(outputter, ostream);
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter)

Example 54 with XMLOutputter

use of org.jdom.output.XMLOutputter in project sling by apache.

the class CreateKarafFeatureDescriptorMojo method executeWithArtifacts.

@Override
protected void executeWithArtifacts() throws MojoExecutionException, MojoFailureException {
    Document doc = new Document();
    Element features = new Element("features");
    doc.setRootElement(features);
    features.setAttribute("name", featuresName);
    Element feature = new Element("feature");
    features.addContent(feature);
    feature.setAttribute("name", featureName);
    feature.setAttribute("version", featureVersion);
    BundleList bundleList = getInitializedBundleList();
    for (StartLevel level : bundleList.getStartLevels()) {
        for (Bundle bundle : level.getBundles()) {
            String bundleRef = String.format("mvn:%s/%s/%s", bundle.getGroupId(), bundle.getArtifactId(), bundle.getVersion());
            feature.addContent(new Element("bundle").setText(bundleRef));
        }
    }
    FileOutputStream out = null;
    try {
        out = new FileOutputStream(outputFile);
        new XMLOutputter(Format.getPrettyFormat().setEncoding("UTF-8")).output(doc, out);
        projectHelper.attachArtifact(project, TYPE, CLASSIFIER, outputFile);
    } catch (IOException e) {
        throw new MojoExecutionException("Unable to write features.xml", e);
    } finally {
        if (out != null) {
            try {
                out.close();
            } catch (IOException e) {
            }
        }
    }
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) BundleList(org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList) Bundle(org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle) Element(org.jdom.Element) FileOutputStream(java.io.FileOutputStream) StartLevel(org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.StartLevel) IOException(java.io.IOException) Document(org.jdom.Document)

Example 55 with XMLOutputter

use of org.jdom.output.XMLOutputter in project beast-mcmc by beast-dev.

the class AntigenicPlotter method writeKML.

private void writeKML(String fileName, String[] labels, double[][][] data) {
    int[] traceOrder = sortTraces(labels);
    //        Element hpdSchema = new Element("Schema");
    //        hpdSchema.setAttribute("id", "HPD_Schema");
    //        hpdSchema.addContent(new Element("SimpleField")
    //                .setAttribute("name", "Label")
    //                .setAttribute("type", "string")
    //                .addContent(new Element("displayName").addContent("Label")));
    //        hpdSchema.addContent(new Element("SimpleField")
    //                .setAttribute("name", "Point")
    //                .setAttribute("type", "double")
    //                .addContent(new Element("displayName").addContent("Point")));
    //        hpdSchema.addContent(new Element("SimpleField")
    //                .setAttribute("name", "Year")
    //                .setAttribute("type", "double")
    //                .addContent(new Element("displayName").addContent("Year")));
    //        hpdSchema.addContent(new Element("SimpleField")
    //                .setAttribute("name", "HPD")
    //                .setAttribute("type", "double")
    //                .addContent(new Element("displayName").addContent("HPD")));
    Element traceSchema = new Element("Schema");
    traceSchema.setAttribute("id", "Trace_Schema");
    traceSchema.addContent(new Element("SimpleField").setAttribute("name", "Label").setAttribute("type", "string").addContent(new Element("displayName").addContent("Label")));
    traceSchema.addContent(new Element("SimpleField").setAttribute("name", "Trace").setAttribute("type", "double").addContent(new Element("displayName").addContent("Trace")));
    traceSchema.addContent(new Element("SimpleField").setAttribute("name", "Year").setAttribute("type", "double").addContent(new Element("displayName").addContent("Year")));
    traceSchema.addContent(new Element("SimpleField").setAttribute("name", "State").setAttribute("type", "double").addContent(new Element("displayName").addContent("State")));
    Element centroidSchema = new Element("Schema");
    centroidSchema.setAttribute("id", "Centroid_Schema");
    centroidSchema.addContent(new Element("SimpleField").setAttribute("name", "Label").setAttribute("type", "string").addContent(new Element("displayName").addContent("Label")));
    centroidSchema.addContent(new Element("SimpleField").setAttribute("name", "Year").setAttribute("type", "double").addContent(new Element("displayName").addContent("Year")));
    centroidSchema.addContent(new Element("SimpleField").setAttribute("name", "Trace").setAttribute("type", "double").addContent(new Element("displayName").addContent("Trace")));
    //        final Element contourFolderElement = new Element("Folder");
    //        Element contourFolderNameElement = new Element("name");
    //        contourFolderNameElement.addContent("HPDs");
    //        contourFolderElement.addContent(contourFolderNameElement);
    final Element traceFolderElement = new Element("Folder");
    Element traceFolderNameElement = new Element("name");
    traceFolderNameElement.addContent("traces");
    traceFolderElement.addContent(traceFolderNameElement);
    final Element centroidFolderElement = new Element("Folder");
    Element centroidFolderNameElement = new Element("name");
    centroidFolderNameElement.addContent("centroids");
    centroidFolderElement.addContent(centroidFolderNameElement);
    Element documentNameElement = new Element("name");
    String documentName = fileName;
    if (documentName.endsWith(".kml"))
        documentName = documentName.replace(".kml", "");
    documentNameElement.addContent(documentName);
    final Element documentElement = new Element("Document");
    documentElement.addContent(documentNameElement);
    documentElement.addContent(traceSchema);
    documentElement.addContent(centroidSchema);
    //        documentElement.addContent(hpdSchema);
    documentElement.addContent(centroidFolderElement);
    documentElement.addContent(traceFolderElement);
    //        documentElement.addContent(contourFolderElement);
    final Element rootElement = new Element("kml");
    rootElement.addContent(documentElement);
    Element traceElement = generateTraceElement(labels, data, traceOrder);
    traceFolderElement.addContent(traceElement);
    Element centroidElement = generateCentroidElement(labels, data, traceOrder);
    centroidFolderElement.addContent(centroidElement);
    //        Element contourElement = generateKDEElement(0.95, labels, data, traceOrder);
    //        contourFolderElement.addContent(contourElement);
    PrintStream resultsStream;
    try {
        resultsStream = new PrintStream(new File(fileName));
        XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat().setTextMode(Format.TextMode.PRESERVE));
        xmlOutputter.output(rootElement, resultsStream);
    } catch (IOException e) {
        System.err.println("Error opening file: " + fileName);
        System.exit(-1);
    }
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Element(org.jdom.Element)

Aggregations

XMLOutputter (org.jdom.output.XMLOutputter)64 Element (org.jdom.Element)34 Document (org.jdom.Document)22 Format (org.jdom.output.Format)22 IOException (java.io.IOException)16 StringWriter (java.io.StringWriter)14 ArrayList (java.util.ArrayList)7 StringReader (java.io.StringReader)5 Writer (java.io.Writer)5 SAXBuilder (org.jdom.input.SAXBuilder)5 FileWriter (java.io.FileWriter)4 List (java.util.List)3 TreeMap (java.util.TreeMap)3 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)3 JDOMException (org.jdom.JDOMException)3 ElementFilter (org.jdom.filter.ElementFilter)3 BufferedOutputStream (java.io.BufferedOutputStream)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2