Example usage for org.jdom2.output DOMOutputter output

List of usage examples for org.jdom2.output DOMOutputter output

Introduction

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

Prototype

public List<org.w3c.dom.Node> output(List<? extends Content> list) throws JDOMException 

Source Link

Document

This converts the JDOM Attribute parameter to a DOM Attr Node, returning the DOM version.

Usage

From source file:com.c4om.autoconf.ulysses.configanalyzer.objectivesextractor.JSchematronValidatorBasedExtractor.java

License:Apache License

/**
 * This implementation is based on JSchematronValidator
 * @see com.c4om.autoconf.ulysses.interfaces.configanalyzer.objectivesextractor.SchematronBasedExtractor#performSchematronValidation(org.jdom2.Document, org.jdom2.Document, java.io.File)
 *//*from  w  w  w .  ja  v  a 2s .  c o m*/
@Override
protected Document performSchematronValidation(Document schematronSchema, Document inputCandidate,
        File workingDirectory) throws SchematronObjectivesExtractionException {
    try {
        DOMOutputter domOutputter = new DOMOutputter();
        org.w3c.dom.Document schematronSchemaW3C = domOutputter.output(schematronSchema);
        org.w3c.dom.Document inputCandidateW3C = domOutputter.output(inputCandidate);
        //We set the working directory to the provided one
        String userDirBackup = System.getProperty("user.dir");
        System.setProperty("user.dir", workingDirectory.getAbsolutePath()); //this is equivalent to a 'cd' console command
        org.w3c.dom.Document resultSVRLW3C = validator.performValidation(inputCandidateW3C,
                schematronSchemaW3C);
        System.setProperty("user.dir", userDirBackup); //We restore the original path
        DOMBuilder domBuilder = new DOMBuilder();
        Document resultSVRL = domBuilder.build(resultSVRLW3C);
        return resultSVRL;
    } catch (SchematronValidationException | JDOMException e) {
        throw new SchematronObjectivesExtractionException(e);
    }
}

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

License:Apache License

/**
 * This method takes an input JDOM2 {@link Document} and a XSLT (as a JDOM2 {@link Document}) 
 * and applies the sheet to the document. The result is returned as a JDOM2 {@link Document}. 
 * @param inputDocument the input document
 * @param xslt the XSLT sheet//  w ww . j a  v  a  2 s .  co  m
 * @return the result of applying the sheet to the document
 * @throws JDOMException if there are problems at JDOM2 parsing
 * @throws SaxonApiException if there are problems related to JDOM2 documents
 * @throws ParserConfigurationException if there are problems at building internal {@link org.w3c.dom.Document} objects used to interact with Saxon API.
 */
public static Document performXSLT(Document inputDocument, Document xslt)
        throws JDOMException, SaxonApiException, ParserConfigurationException {
    //First, we convert JDOM2 documents to org.w3c.dom.Document
    DOMOutputter domOutputter = new DOMOutputter();
    org.w3c.dom.Document w3cXSLT = domOutputter.output(xslt);
    org.w3c.dom.Document w3cInput = domOutputter.output(inputDocument);
    Processor processor = new Processor(false);

    DocumentBuilderFactory w3cDocumentBuilderFactory = DocumentBuilderFactory.newInstance();
    w3cDocumentBuilderFactory.setNamespaceAware(true);
    DocumentBuilder documentBuilder = w3cDocumentBuilderFactory.newDocumentBuilder();
    org.w3c.dom.Document w3cDestinationDocument = documentBuilder.newDocument();

    Source w3cXSLTSource = new DOMSource(w3cXSLT);
    Source w3cInputSource = new DOMSource(w3cInput);
    Destination destination = new DOMDestination(w3cDestinationDocument);

    XsltCompiler comp = processor.newXsltCompiler();
    XsltExecutable executable = comp.compile(w3cXSLTSource);
    XsltTransformer transformer = executable.load();
    XdmNode xdmInput = processor.newDocumentBuilder().build(w3cInputSource);
    transformer.setInitialContextNode(xdmInput);
    transformer.setDestination(destination);
    transformer.transform();

    DOMBuilder domBuilder = new DOMBuilder();
    Document destinationDocument = domBuilder.build(w3cDestinationDocument);

    return destinationDocument;
}

From source file:com.izforge.izpack.util.xmlmerge.merge.DefaultXmlMerge.java

License:Open Source License

@Override
public org.w3c.dom.Document merge(org.w3c.dom.Document[] sources) throws AbstractXmlMergeException {
    DOMBuilder domb = new DOMBuilder();

    // to save all XML files as JDOM objects
    Document[] docs = new Document[sources.length];

    for (int i = 0; i < sources.length; i++) {
        // ask JDOM to parse the given inputStream
        docs[i] = domb.build(sources[i]);
    }/*  w w  w . j a  va2s  .co m*/

    Document result = doMerge(docs);

    DOMOutputter outputter = new DOMOutputter();

    try {
        return outputter.output(result);
    } catch (JDOMException e) {
        throw new DocumentException(result, e);
    }
}

From source file:com.rometools.rome.io.WireFeedOutput.java

License:Open Source License

/**
 * Creates a W3C DOM document for the given WireFeed.
 * <p>//from   www . ja va2s .c  o  m
 * This method does not use the feed encoding property.
 * <p>
 * NOTE: This method delages to the 'Document WireFeedOutput#outputJDom(WireFeed)'.
 * <p>
 *
 * @param feed Abstract feed to create W3C DOM document from. The type of the WireFeed must
 *            match the type given to the FeedOuptut constructor.
 * @return the W3C DOM document for the given WireFeed.
 * @throws IllegalArgumentException thrown if the feed type of the WireFeedOutput and WireFeed
 *             don't match.
 * @throws FeedException thrown if the W3C DOM document for the feed could not be created.
 *
 */
public org.w3c.dom.Document outputW3CDom(final WireFeed feed) throws IllegalArgumentException, FeedException {
    final Document doc = outputJDom(feed);
    final DOMOutputter outputter = new DOMOutputter();
    try {
        return outputter.output(doc);
    } catch (final JDOMException jdomEx) {
        throw new FeedException("Could not create DOM", jdomEx);
    }
}

From source file:com.sun.syndication.io.WireFeedOutput.java

License:Open Source License

/**
 * Creates a W3C DOM document for the given WireFeed.
 * <p>// www  . j av a 2  s .  c  om
 * This method does not use the feed encoding property.
 * <p>
 * NOTE: This method delages to the 'Document WireFeedOutput#outputJDom(WireFeed)'.
 * <p>
 * @param feed Abstract feed to create W3C DOM document from. The type of the WireFeed must match
 *        the type given to the FeedOuptut constructor.
 * @return the W3C DOM document for the given WireFeed.
 * @throws IllegalArgumentException thrown if the feed type of the WireFeedOutput and WireFeed don't match.
 * @throws FeedException thrown if the W3C DOM document for the feed could not be created.
 *
 */
public org.w3c.dom.Document outputW3CDom(WireFeed feed) throws IllegalArgumentException, FeedException {
    Document doc = outputJDom(feed);
    DOMOutputter outputter = new DOMOutputter();
    try {
        return outputter.output(doc);
    } catch (JDOMException jdomEx) {
        throw new FeedException("Could not create DOM", jdomEx);
    }
}

From source file:de.unigoettingen.sub.search.opac.ConfigOpacCatalogue.java

License:Open Source License

public Node executeBeautifier(Node myHitlist) {
    /* Ausgabe des Opac-Ergebnissen in Datei */

    //        if (!ConfigurationHelper.getInstance().getDebugFolder().equals("") && Files.isWritable(Paths.get(ConfigurationHelper.getInstance().getDebugFolder()))) {
    //            debugMyNode(myHitlist, ConfigurationHelper.getInstance().getDebugFolder() + "/opacBeautifyBefore.xml");
    //        }//from   w  ww .  j a v a  2  s .c  o m

    /*
     * --------------------- aus dem Dom-Node ein JDom-Object machen -------------------
     */
    Document doc = new DOMBuilder().build(myHitlist.getOwnerDocument());

    /*
     * --------------------- Im JDom-Object alle Felder durchlaufen und die notwendigen Ersetzungen vornehmen -------------------
     */
    /* alle Records durchlaufen */
    List<Element> elements = doc.getRootElement().getChildren();
    for (Element el : elements) {
        // Element el = (Element) it.next();
        /* in jedem Record den Beautifier anwenden */
        executeBeautifierForElement(el);
    }

    /*
     * --------------------- aus dem JDom-Object wieder ein Dom-Node machen -------------------
     */
    DOMOutputter doutputter = new DOMOutputter();
    try {
        myHitlist = doutputter.output(doc);
        myHitlist = myHitlist.getFirstChild();
    } catch (JDOMException e) {
        logger.error("JDOMException in executeBeautifier(Node)", e);
    }

    /* Ausgabe des berarbeiteten Opac-Ergebnisses */
    if (!ConfigurationHelper.getInstance().getDebugFolder().equals("") && StorageProvider.getInstance()
            .isWritable(Paths.get(ConfigurationHelper.getInstance().getDebugFolder()))) {
        debugMyNode(myHitlist, ConfigurationHelper.getInstance().getDebugFolder() + "/opacBeautifyAfter.xml");
    }
    return myHitlist;
}

From source file:domainapp.app.services.export.ExportToWordMenu.java

License:Apache License

private org.w3c.dom.Document asInputW3cDocument(final List<QuickObject> items) throws JDOMException {
    final Document jdomDoc = asInputDocument(items);

    final DOMOutputter domOutputter = new DOMOutputter();
    return domOutputter.output(jdomDoc);
}

From source file:domainapp.app.services.export.PublishContributionsForMenu.java

License:Apache License

private org.w3c.dom.Document asInputW3cDocument(final Menu menu) throws JDOMException {
    final Document jdomDoc = asInputDocument(menu);

    final DOMOutputter domOutputter = new DOMOutputter();
    return domOutputter.output(jdomDoc);
}

From source file:domainapp.app.services.export.PublishContributionsForOrder.java

License:Apache License

private org.w3c.dom.Document asInputW3cDocument(final Order order) throws JDOMException {
    final Document jdomDoc = asInputDocument(order);

    final DOMOutputter domOutputter = new DOMOutputter();
    return domOutputter.output(jdomDoc);
}

From source file:domainapp.app.services.export.PublishContributionsForSupplier.java

License:Apache License

private org.w3c.dom.Document asInputW3cDocument(final Supplier supplier, final Event event)
        throws JDOMException {
    final Document jdomDoc = asInputDocument(supplier, event);

    final DOMOutputter domOutputter = new DOMOutputter();
    return domOutputter.output(jdomDoc);
}