Example usage for org.jdom2.output XMLOutputter outputString

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

Introduction

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

Prototype

public final String outputString(EntityRef entity) 

Source Link

Document

Return a string representing an EntityRef .

Usage

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

From source file:it.intecs.pisa.openCatalogue.solr.ingester.BaseIngester.java

private FileFilesystem storeMetadata(org.jdom2.Document metadata, boolean isValid) throws IOException {
    if (metadataRepository != null) {
        XPathExpression<Element> xpath = XPathFactory.instance().compile(idXPath, Filters.element());

        String key = xpath.evaluateFirst(metadata.getRootElement()).getTextTrim().replace(":", "_").replace(".",
                "_");
        FileFilesystem fs = null;//ww w .  j  a va2s.  c  om
        if (isValid) {
            fs = new FileFilesystem(metadataRepository.getAbsolutePath() + "/" + key + ".xml");
        } else {
            fs = new FileFilesystem(metadataRepository.getAbsolutePath() + "/" + key + ".notValid.xml");
        }
        XMLOutputter outputter = new XMLOutputter();
        String metadataString = outputter.outputString(metadata);
        byte[] b = metadataString.getBytes();
        fs.getOutputStream().write(b);
        return fs;
    } else {
        return null;
    }
}

From source file:it.intecs.pisa.openCatalogue.solr.ingester.BaseIngester.java

private boolean validateMetadata(Document metadata) {
    if (schemaRoot != null && schemaFile != null) {
        try {/*from   www . j  a  va  2s  . c o m*/
            XMLOutputter outputter = new XMLOutputter();
            String metadataString = outputter.outputString(metadata);
            byte[] b = metadataString.getBytes();
            return SchemasUtil.SAXvalidate(new ByteArrayInputStream(b), schemaFile, schemaRoot, schemaCache);
        } catch (Exception e) {
            return false;
        }
    } else {
        return true;
    }
}

From source file:json.JSONConverter.java

License:Apache License

@Override
public final String toString() {
    XMLOutputter sortie = new XMLOutputter();
    return sortie.outputString(document);
}

From source file:json.JSONConverter.java

License:Apache License

/**
 * . Gives a string representation of the object
 * /*ww w  . ja  v  a  2s .  com*/
 * @param format
 *            uses prettyFormat if format is 2
 * @return String representation of the object
 */
public final String toString(int format) {
    XMLOutputter sortie;
    if (format == 2) {
        sortie = new XMLOutputter(Format.getPrettyFormat());
    } else {
        sortie = new XMLOutputter();
    }
    return sortie.outputString(document);
}

From source file:lu.list.itis.dkd.aig.util.DocumentConverter.java

License:Apache License

/**
 * Method for converting a {@link Document} instance into its XML
 * {@link String} representation.//  w  w w. java 2s. co  m
 *
 * @param document
 *            The {@link Document} instance to convert.
 * @return The {@link String} representation of the document using an
 *         {@link XMLOutputter} and setting {@link Format} to pretty print.
 */
@SuppressWarnings("null")
public static String convertDocumentToString(final Document document) {

    final XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
    return outputter.outputString(document);
}

From source file:lu.list.itis.dkd.aig.util.DocumentConverter.java

License:Apache License

/**
 * PATCH: as template content is not using CDATA try to remove trailing
 * white spaces and blank lines.//w w w . ja va2  s  .  c  om
 * 
 * @param document
 * @return well formated XML string
 */
private static String removeTrailingEmptyElements(final Document document) {
    XMLOutputter format = new XMLOutputter();
    format.setFormat(Format.getCompactFormat());
    return format.outputString(document);
}

From source file:main.GenerateHTML.java

License:Open Source License

/**
 * /* w  w  w.jav  a  2s .  c o  m*/
 * @param inName
 * @throws IOException
 */
static void printHTMLFrame(String inName) throws IOException {
    Format expanded = Format.getPrettyFormat().setExpandEmptyElements(true);
    XMLOutputter out = new XMLOutputter(expanded);

    Element element = addHeader("Sources")
            .addContent(new Element("frameset").setAttribute("id", "mainframe").setAttribute("cols", "20%, 80%")
                    .addContent(new Element("frameset").setAttribute("id", "mainframe")
                            .setAttribute("rows", "20%, 50%, 30%")
                            .addContent(new Element("frame").setAttribute("name", "tags").setAttribute("src",
                                    FileUtils.getRelTagListeName()))
                            .addContent(new Element("frame").setAttribute("name", "source").setAttribute("src",
                                    FileUtils.getRelNilName()))
                            .addContent(new Element("frame").setAttribute("name", "target").setAttribute("src",
                                    FileUtils.getRelNilName())))
                    .addContent(new Element("frameset").setAttribute("id", "mainframe")
                            .setAttribute("rows", "50%, 50%")
                            .addContent(new Element("frame").setAttribute("name", "doku").setAttribute("src",
                                    FileUtils.getRelDxygeDokuName()))
                            .addContent(new Element("frame").setAttribute("name", "details").setAttribute("src",
                                    FileUtils.getRelNilName()))));

    outFile(inName, out.outputString(element));
}

From source file:main.GenerateHTML.java

License:Open Source License

/**
 * /*  w  ww .  j  a v  a2  s .c  o m*/
 * 
 * @throws IOException
 */
static void printHTMLNil() throws IOException {
    Format expanded = Format.getPrettyFormat().setExpandEmptyElements(true);
    XMLOutputter out = new XMLOutputter(expanded);

    Element element = new Element("html").addContent(new Element("head"))
            .addContent(new Element("body").addContent(new Element("p").setText("Leer")));

    outFile(FileUtils.getNilName(), out.outputString(element));
}

From source file:main.GenerateHTML.java

License:Open Source License

/**
 * //from   www  . j a  va 2s. c o m
 * @param listeSource
 * @param listeTyp
 * @param nodeLinkListe
 * @param inNodeTag
 * @throws IOException
 */
static void printHTMLSource(List<NodeSource> listeSource, List<NodeTyp> listeTyp,
        List<NodeTarget> nodeLinkListe, NodeTag inNodeTag) throws IOException {
    Format expanded = Format.getPrettyFormat().setExpandEmptyElements(true);
    XMLOutputter out = new XMLOutputter(expanded);

    Element element = new Element("html").addContent(new Element("title").setText("Sources"));
    Element body = new Element("body");
    element.addContent(body);

    int count = 0;
    for (NodeSource node : listeSource) {
        if (node.getName().equals(inNodeTag.getName())) {
            count++;
        }
    }
    if (count == 0) {
        body.addContent(new Element("p").setText(String.format("No reference for: %s", inNodeTag.getName())));
    } else {
        for (NodeSource node : listeSource) {
            if (node.getName().equals(inNodeTag.getName())) {
                body.addContent(new Element("p").addContent(new Element("a")
                        .setText(String.format("%s %s", node.getName(), node.getNummer()))
                        .setAttribute("href", FileUtils.getRelLinkName(node)).setAttribute("target", "target")
                        .setAttribute("title", "Beschreibung der Klasse").setAttribute("onclick",
                                String.format("top.doku.location='%s'; return true;", node.getFileName()))));

                GenerateHTML.printHTMLLink(node, listeTyp, nodeLinkListe);
            }
        }
    }

    outFile(FileUtils.getSourceName(inNodeTag), out.outputString(element));
}