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:ca.nrc.cadc.vos.client.VOSClientUtil.java

License:Open Source License

public static String xmlString(Document doc) {
    XMLOutputter outputter = new XMLOutputter();
    outputter.setFormat(Format.getPrettyFormat());
    return outputter.outputString(doc);
}

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 a v  a  2s .co m*/
    // 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  w w  w  .  ja  v a  2 s . co m
    // 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: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
 *//*from  w  w  w  . jav a  2  s.  c om*/
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));
}

From source file:com.c4om.utils.xmlutils.JDOMUtils.java

License:Apache License

/**
 * Method that converts a JDOM2 {@link Document} to String
 * @param document the document//from w  w  w  . jav  a  2 s  .  c  o  m
 * @return the string
 */
public static String convertJDOMDocumentToString(Document document) {
    Format xmlFormat = Format.getPrettyFormat();
    xmlFormat.setLineSeparator(LineSeparator.SYSTEM);
    XMLOutputter outputter = new XMLOutputter(xmlFormat);
    String result = outputter.outputString(document);
    return result;
}

From source file:com.googlecode.mipnp.mediaserver.cds.DidlLiteDocument.java

License:Open Source License

@Override
public String toString() {
    Format format = Format.getRawFormat();
    format.setOmitDeclaration(true);//from w w w  . j  a va  2  s. c  o m
    XMLOutputter outputter = new XMLOutputter(format);
    return outputter.outputString(document);
}

From source file:com.htm.utils.Utilities.java

License:Open Source License

public static String getStringFromXMLDoc(Document doc) {
    XMLOutputter out = new XMLOutputter();
    return out.outputString(doc);
}

From source file:com.init.octo.query.Query.java

License:Open Source License

/**
 * This method initialises the object with a parameters object. This will
 * replace any parameters in the query text with values from the parameters
 * object.//  w  ww.  j a va  2s  .c om
 * 
 * @param parameters
 *            - an XML structure containing current definitions of
 *            parameters
 * @throws SQLException
 */

public void expandParameters(Document parameters) throws SQLException {
    XMLOutputter xout = new XMLOutputter(); // Format.getPrettyFormat());
    log.debug("parameters XML: " + xout.outputString(parameters));

    expandedQuery = StringUtils.expand(queryText.toString(), parameters.getRootElement());

    log.debug("EXPANDED QUERY [" + expandedQuery + "]");

    /** Close everything down... * */

    // firstFetch = true;
    if (rs != null) {
        rs.close();
        rs = null;
    }
    if (statement != null) {
        statement.close();
        statement = null;
    }

}

From source file:com.novell.ldapchai.cr.ChaiResponseSet.java

License:Open Source License

static String rsToChaiXML(final ChaiResponseSet rs) throws ChaiValidationException, ChaiOperationException {
    final Element rootElement = new Element(XML_NODE_ROOT);
    rootElement.setAttribute(XML_ATTRIBUTE_MIN_RANDOM_REQUIRED,
            String.valueOf(rs.getChallengeSet().getMinRandomRequired()));
    rootElement.setAttribute(XML_ATTRIBUTE_LOCALE, rs.getChallengeSet().getLocale().toString());
    rootElement.setAttribute(XML_ATTRIBUTE_VERSION, VALUE_VERSION);
    rootElement.setAttribute(XML_ATTRIBUTE_CHAI_VERSION, ChaiConstant.CHAI_API_VERSION);

    if (rs.caseInsensitive) {
        rootElement.setAttribute(XML_ATTRIBUTE_CASE_INSENSITIVE, "true");
    }/*from   w ww.  j  a  va2 s.  com*/

    if (rs.csIdentifier != null) {
        rootElement.setAttribute(XML_ATTRIBUTE_CHALLENGE_SET_IDENTIFER, rs.csIdentifier);
    }

    if (rs.timestamp != null) {
        rootElement.setAttribute(XML_ATTRIBUTE_TIMESTAMP, DATE_FORMATTER.format(rs.timestamp));
    }

    if (rs.crMap != null) {
        for (final Challenge loopChallenge : rs.crMap.keySet()) {
            final Answer answer = rs.crMap.get(loopChallenge);
            final Element responseElement = challengeToXml(loopChallenge, answer, XML_NODE_RESPONSE);
            rootElement.addContent(responseElement);
        }
    }

    if (rs.helpdeskCrMap != null) {
        for (final Challenge loopChallenge : rs.helpdeskCrMap.keySet()) {
            final Answer answer = rs.helpdeskCrMap.get(loopChallenge);
            final Element responseElement = challengeToXml(loopChallenge, answer, XML_NODE_HELPDESK_RESPONSE);
            rootElement.addContent(responseElement);
        }
    }

    final Document doc = new Document(rootElement);
    final XMLOutputter outputter = new XMLOutputter();
    final Format format = Format.getRawFormat();
    format.setTextMode(Format.TextMode.PRESERVE);
    format.setLineSeparator("");
    outputter.setFormat(format);
    return outputter.outputString(doc);
}

From source file:com.novell.ldapchai.impl.edir.NmasResponseSet.java

License:Open Source License

static String csToNmasXML(final ChallengeSet cs, final String guidValue) {
    final Element rootElement = new Element(NMAS_XML_ROOTNODE);
    rootElement.setAttribute(NMAS_XML_ATTR_RANDOM_COUNT, String.valueOf(cs.getMinRandomRequired()));
    if (guidValue != null) {
        rootElement.setAttribute("GUID", guidValue);
    } else {/* ww  w .jav a  2  s. c o  m*/
        rootElement.setAttribute("GUID", "0");
    }

    for (final Challenge challenge : cs.getChallenges()) {
        final Element loopElement = new Element(NMAS_XML_NODE_CHALLENGE);
        if (challenge.getChallengeText() != null) {
            loopElement.setText(challenge.getChallengeText());
        }

        if (challenge.isAdminDefined()) {
            loopElement.setAttribute(NMAS_XML_ATTR_DEFINE, "Admin");
        } else {
            loopElement.setAttribute(NMAS_XML_ATTR_DEFINE, "User");
        }

        if (challenge.isRequired()) {
            loopElement.setAttribute(NMAS_XML_ATTR_TYPE, "Required");
        } else {
            loopElement.setAttribute(NMAS_XML_ATTR_TYPE, "Random");
        }

        loopElement.setAttribute(NMAS_XML_ATTR_MIN_LENGTH, String.valueOf(challenge.getMinLength()));
        loopElement.setAttribute(NMAS_XML_ATTR_MAX_LENGTH, String.valueOf(challenge.getMaxLength()));

        rootElement.addContent(loopElement);
    }

    final XMLOutputter outputter = new XMLOutputter();
    final Format format = Format.getRawFormat();
    format.setTextMode(Format.TextMode.PRESERVE);
    format.setLineSeparator("");
    outputter.setFormat(format);
    return outputter.outputString(rootElement);
}