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() 

Source Link

Document

This will create an XMLOutputter with a default Format and XMLOutputProcessor .

Usage

From source file:org.educautecisystems.core.chat.elements.UserChat.java

License:Open Source License

public static String generateXMLFromList(ArrayList<UserChat> users) {
    Document xmlDocument = new Document();

    Namespace baseNamespace = Namespace.getNamespace("chat", "http://free.chat.com/");
    Element root = new Element("users", baseNamespace);

    for (UserChat user : users) {
        Element userXml = new Element("user", baseNamespace);

        userXml.addContent(new Element("id").setText("" + user.getId()));
        userXml.addContent(new Element("real_name").setText(user.getRealName()));
        userXml.addContent(new Element("nickname").setText(user.getNickName()));

        root.addContent(userXml);//from   w w w .  jav a 2  s .c  om
    }

    xmlDocument.setRootElement(root);
    XMLOutputter xmlOutputter = new XMLOutputter();

    return xmlOutputter.outputString(xmlDocument);
}

From source file:org.esa.s2tbx.dataio.s2.gml.GmlFilter.java

License:Open Source License

public GmlFilter() {
    this.xmlOutput = new XMLOutputter();
}

From source file:org.geoserver.backuprestore.tasklet.AbstractCatalogBackupRestoreTasklet.java

License:Open Source License

/**
 * This method dumps the current Backup index: - List of Workspaces - List of Stores - List of
 * Layers/*  w  ww.  j  av a 2  s. co  m*/
 *
 * @param sourceFolder
 * @throws IOException
 */
protected void dumpBackupIndex(Resource sourceFolder) throws IOException {
    Element root = new Element("Index");
    Document doc = new Document();

    for (WorkspaceInfo ws : getCatalog().getWorkspaces()) {
        if (!filteredResource(ws, false)) {
            Element workspace = new Element("Workspace");
            workspace.addContent(new Element("Name").addContent(ws.getName()));
            root.addContent(workspace);

            for (DataStoreInfo ds : getCatalog().getStoresByWorkspace(ws.getName(), DataStoreInfo.class)) {
                if (!filteredResource(ds, ws, true, StoreInfo.class)) {
                    Element store = new Element("Store");
                    store.setAttribute("type", "DataStoreInfo");
                    store.addContent(new Element("Name").addContent(ds.getName()));
                    workspace.addContent(store);

                    for (FeatureTypeInfo ft : getCatalog().getFeatureTypesByDataStore(ds)) {
                        if (!filteredResource(ft, ws, true, ResourceInfo.class)) {
                            for (LayerInfo ly : getCatalog().getLayers(ft)) {
                                if (!filteredResource(ly, ws, true, LayerInfo.class)) {
                                    Element layer = new Element("Layer");
                                    layer.setAttribute("type", "VECTOR");
                                    layer.addContent(new Element("Name").addContent(ly.getName()));
                                    store.addContent(layer);
                                }
                            }
                        }
                    }
                }
            }

            for (CoverageStoreInfo cs : getCatalog().getStoresByWorkspace(ws.getName(),
                    CoverageStoreInfo.class)) {
                if (!filteredResource(cs, ws, true, StoreInfo.class)) {
                    Element store = new Element("Store");
                    store.setAttribute("type", "CoverageStoreInfo");
                    store.addContent(new Element("Name").addContent(cs.getName()));
                    workspace.addContent(store);

                    for (CoverageInfo ci : getCatalog().getCoveragesByCoverageStore(cs)) {
                        if (!filteredResource(ci, ws, true, ResourceInfo.class)) {
                            for (LayerInfo ly : getCatalog().getLayers(ci)) {
                                if (!filteredResource(ly, ws, true, LayerInfo.class)) {
                                    Element layer = new Element("Layer");
                                    layer.setAttribute("type", "RASTER");
                                    layer.addContent(new Element("Name").addContent(ly.getName()));
                                    store.addContent(layer);
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    if (filterIsValid()) {
        Element filter = new Element("Filters");
        if (getFilters().length > 0 && getFilters()[0] != null) {
            Element wsFilter = new Element("Filter");
            wsFilter.setAttribute("type", "WorkspaceInfo");
            wsFilter.addContent(new Element("ECQL").addContent(ECQL.toCQL(getFilters()[0])));
            filter.addContent(wsFilter);
        }

        if (getFilters().length > 1 && getFilters()[1] != null) {
            Element siFilter = new Element("Filter");
            siFilter.setAttribute("type", "StoreInfo");
            siFilter.addContent(new Element("ECQL").addContent(ECQL.toCQL(getFilters()[1])));
            filter.addContent(siFilter);
        }

        if (getFilters().length > 2 && getFilters()[2] != null) {
            Element liFilter = new Element("Filter");
            liFilter.setAttribute("type", "LayerInfo");
            liFilter.addContent(new Element("ECQL").addContent(ECQL.toCQL(getFilters()[2])));
            filter.addContent(liFilter);
        }

        root.addContent(filter);
    }

    doc.setRootElement(root);

    XMLOutputter outter = new XMLOutputter();
    outter.setFormat(Format.getPrettyFormat());
    outter.output(doc, new FileWriter(sourceFolder.get(BR_INDEX_XML).file()));
}

From source file:org.goobi.managedbeans.ProcessBean.java

License:Open Source License

/**
 * Create the database information xml file and send it to the servlet output stream
 *//*from  w  ww . ja  v a  2s  .c o  m*/
public void downloadProcessDatebaseInformation() {
    FacesContext facesContext = FacesContextHelper.getCurrentFacesContext();
    if (!facesContext.getResponseComplete()) {

        org.jdom2.Document doc = new ExportXmlLog().createExtendedDocument(myProzess);

        String outputFileName = myProzess.getId() + "_db_export.xml";

        HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();

        ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext();
        String contentType = servletContext.getMimeType(outputFileName);
        response.setContentType(contentType);
        response.setHeader("Content-Disposition", "attachment;filename=\"" + outputFileName + "\"");

        try {
            ServletOutputStream out = response.getOutputStream();
            XMLOutputter outp = new XMLOutputter();
            outp.setFormat(Format.getPrettyFormat());
            outp.output(doc, out);
            out.flush();

        } catch (IOException e) {
            Helper.setFehlerMeldung("could not export database information: ", e);
        }
        facesContext.responseComplete();
    }
}

From source file:org.goobi.production.export.ExportXmlLog.java

License:Open Source License

/**
 * This method exports the production metadata as xml to a given stream.
 * //from  www .j av  a 2s.c  om
 * @param process the process to export
 * @param os the OutputStream to write the contents to
 * @throws IOException
 * @throws ExportFileException
 */
@Override
public void startExport(Process process, OutputStream os, String xslt) throws IOException {
    try {
        Document doc = createDocument(process, true);

        XMLOutputter outp = new XMLOutputter();
        outp.setFormat(Format.getPrettyFormat());

        outp.output(doc, os);
        os.close();

    } catch (Exception e) {
        throw new IOException(e);
    }
}

From source file:org.goobi.production.export.ExportXmlLog.java

License:Open Source License

/**
 * This method exports the production metadata for al list of processes as a single file to a given stream.
 * //from   w  w w. java 2s.c o  m
 * @param processList
 * @param outputStream
 * @param xslt
 */

public void startExport(List<Process> processList, OutputStream outputStream, String xslt) {
    Document answer = new Document();
    Element root = new Element("processes");
    answer.setRootElement(root);
    Namespace xmlns = Namespace.getNamespace("http://www.goobi.io/logfile");

    Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    root.addNamespaceDeclaration(xsi);
    root.setNamespace(xmlns);
    Attribute attSchema = new Attribute("schemaLocation", "http://www.goobi.io/logfile" + " XML-logfile.xsd",
            xsi);
    root.setAttribute(attSchema);
    for (Process p : processList) {
        Document doc = createDocument(p, false);
        Element processRoot = doc.getRootElement();
        processRoot.detach();
        root.addContent(processRoot);
    }

    XMLOutputter outp = new XMLOutputter();
    outp.setFormat(Format.getPrettyFormat());

    try {

        outp.output(answer, outputStream);
    } catch (IOException e) {

    } finally {
        if (outputStream != null) {
            try {
                outputStream.close();
            } catch (IOException e) {
                outputStream = null;
            }
        }
    }

}

From source file:org.graphwalker.StatisticsManager.java

License:Open Source License

public String getCurrentStatisticXml() {
    XMLOutputter outputter = new XMLOutputter();
    return outputter.outputString(getCurrentStatistic());
}

From source file:org.graphwalker.StatisticsManager.java

License:Open Source License

public String getFullProgressXml() {
    XMLOutputter outputter = new XMLOutputter();
    return outputter.outputString(this.progress);
}

From source file:org.helm.notation2.tools.xHelmNotationExporter.java

License:Open Source License

/**
 * method to get xhelm for the helm2 notation with the new functionality
 *
 * @param helm2notation, HELM2Notation object
 * @return xhelm/*from   www  .j  a  v a2s. c  om*/
 * @throws MonomerException
 * @throws JDOMException
 * @throws IOException
 * @throws ChemistryException
 */
public static String getXHELM2(HELM2Notation helm2notation)
        throws MonomerException, IOException, JDOMException, ChemistryException {
    set = new HashSet<Monomer>();
    Element root = new Element(xHelmNotationExporter.XHELM_ELEMENT);

    Document doc = new Document(root);

    Element helmElement = new Element(xHelmNotationExporter.HELM_NOTATION_ELEMENT);
    helmElement.setText(helm2notation.toHELM2());

    root.addContent(helmElement);

    Element monomerListElement = new Element(xHelmNotationExporter.MONOMER_LIST_ELEMENT);

    /* save all adhocMonomers */
    for (MonomerNotation monomernotation : MethodsMonomerUtils
            .getListOfMonomerNotation(helm2notation.getListOfPolymers())) {
        /* get all elements of an rna */
        if (monomernotation instanceof MonomerNotationUnitRNA) {
            for (MonomerNotationUnit unit : ((MonomerNotationUnitRNA) monomernotation).getContents()) {
                addAdHocMonomer(unit);
            }
        } else {
            addAdHocMonomer(monomernotation);

        }

    }
    /* give the adhocMonomer's information */
    for (Monomer distinctmonomer : set) {
        Element monomerElement = MonomerParser.getMonomerElement(distinctmonomer);
        monomerListElement.getChildren().add(monomerElement);
    }

    root.addContent(monomerListElement);
    XMLOutputter xmlOutput = new XMLOutputter();
    // display nice
    xmlOutput.setFormat(Format.getPrettyFormat());
    return xmlOutput.outputString(doc);
}

From source file:org.helm.notation2.tools.xHelmNotationExporter.java

License:Open Source License

/**
 * method to get xhelm for the helm notation, only if it was possible to
 * convert the helm in the old format/* www.  j  a  va  2 s. c  om*/
 *
 * @param helm2notation, HELM2Notation object
 * @return xhelm
 * @throws MonomerException
 * @throws HELM1FormatException
 * @throws JDOMException
 * @throws IOException
 * @throws NotationException
 * @throws CTKException
 * @throws ValidationException
 * @throws ChemistryException if the Chemistry Engine can not be initialized
 */
public static String getXHELM(HELM2Notation helm2notation) throws MonomerException, HELM1FormatException,
        IOException, JDOMException, NotationException, CTKException, ValidationException, ChemistryException {
    set = new HashSet<Monomer>();
    Element root = new Element(xHelmNotationExporter.XHELM_ELEMENT);

    Document doc = new Document(root);

    Element helmElement = new Element(xHelmNotationExporter.HELM_NOTATION_ELEMENT);
    helmElement.setText(HELM1Utils.getStandard(helm2notation));

    root.addContent(helmElement);

    Element monomerListElement = new Element(xHelmNotationExporter.MONOMER_LIST_ELEMENT);

    /* save all adhocMonomers in the set */
    for (MonomerNotation monomernotation : MethodsMonomerUtils
            .getListOfMonomerNotation(helm2notation.getListOfPolymers())) {
        /* get all elements of an rna */
        if (monomernotation instanceof MonomerNotationUnitRNA) {
            for (MonomerNotationUnit unit : ((MonomerNotationUnitRNA) monomernotation).getContents()) {
                addAdHocMonomer(unit);
            }
        } else {
            addAdHocMonomer(monomernotation);
        }
    }

    /* give adhoc monomer's information */
    for (Monomer distinctmonomer : set) {
        Element monomerElement = MonomerParser.getMonomerElement(distinctmonomer);
        monomerListElement.getChildren().add(monomerElement);
    }

    root.addContent(monomerListElement);

    XMLOutputter xmlOutput = new XMLOutputter();
    // display nice
    xmlOutput.setFormat(Format.getPrettyFormat());

    return xmlOutput.outputString(doc);

}