Example usage for org.jdom2 Document getDocType

List of usage examples for org.jdom2 Document getDocType

Introduction

In this page you can find the example usage for org.jdom2 Document getDocType.

Prototype

public DocType getDocType() 

Source Link

Document

This will return the DocType declaration for this Document, or null if none exists.

Usage

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

License:Open Source License

/**
 * Performs the actual merge./*from  w w  w .  j a va  2 s  . co m*/
 *
 * @param docs The documents to merge. The first doc is assumed to be the original one to apply patches against.
 * @return The merged result document
 * @throws AbstractXmlMergeException If an error occurred during the merge
 */
private Document doMerge(Document[] docs) throws AbstractXmlMergeException {
    Document originalDoc = docs[0];
    Element origRootElement = originalDoc.getRootElement();

    for (int i = 1; i < docs.length; i++) {
        Element comparedRootElement = docs[i].getRootElement();

        Document output = new Document();
        if (originalDoc.getDocType() != null) {
            output.setDocType((DocType) originalDoc.getDocType().clone());
        }
        output.setRootElement(new Element("root"));
        Element outputRootElement = output.getRootElement();

        m_rootMergeAction.perform(origRootElement, comparedRootElement, outputRootElement);

        Element root = (Element) outputRootElement.getChildren().get(0);
        root.detach();

        sortRootChildrenRecursive(root);

        originalDoc.setRootElement(root);
    }

    return originalDoc;
}

From source file:com.rometools.rome.io.impl.RSS091NetscapeParser.java

License:Open Source License

@Override
public boolean isMyType(final Document document) {

    final Element rssRoot = document.getRootElement();
    final String name = rssRoot.getName();
    final Attribute version = rssRoot.getAttribute("version");
    final DocType docType = document.getDocType();

    return name.equals(ELEMENT_NAME) && version != null && version.getValue().equals(getRSSVersion())
            && docType != null && ELEMENT_NAME.equals(docType.getElementName())
            && PUBLIC_ID.equals(docType.getPublicID()) && SYSTEM_ID.equals(docType.getSystemID());

}

From source file:com.sun.syndication.io.impl.RSS091NetscapeParser.java

License:Open Source License

public boolean isMyType(Document document) {
    boolean ok = false;
    Element rssRoot = document.getRootElement();
    ok = rssRoot.getName().equals("rss");
    if (ok) {// ww w. j a v  a 2s . co  m
        ok = false;
        Attribute version = rssRoot.getAttribute("version");
        if (version != null) {
            ok = version.getValue().equals(getRSSVersion());
            if (ok) {
                ok = false;
                DocType docType = document.getDocType();

                if (docType != null) {
                    ok = ELEMENT_NAME.equals(docType.getElementName());
                    ok = ok && PUBLIC_ID.equals(docType.getPublicID());
                    ok = ok && SYSTEM_ID.equals(docType.getSystemID());
                }
            }
        }
    }
    return ok;
}

From source file:de.altimos.util.asset.ext.XmlDocument.java

License:Apache License

@SuppressWarnings("rawtypes")
public XmlDocument(AssetKey key, Document doc) {
    super();/*from  w  w w.j  av a  2  s.c  o  m*/
    if (doc != null) {
        setDocType(doc.getDocType());
        setBaseURI(doc.getBaseURI());
        setContent(doc.getRootElement().detach());
    }
    this.key = key;
}

From source file:org.mycore.common.content.MCRJDOMContent.java

License:Open Source License

/**
 * @param jdom the JDOM XML document to read from 
 *//*from  w  ww  .j a v a2s  . c o m*/
public MCRJDOMContent(Document jdom) {
    super();
    this.jdom = jdom;
    super.docType = jdom.getDocType() == null ? jdom.getRootElement().getName()
            : jdom.getDocType().getElementName();
}

From source file:se.miun.itm.input.util.xml.SAXUtil.java

License:Open Source License

private static se.miun.itm.input.model.Document getWrapper(Document document) {
    DocType dt = document.getDocType();
    document.setDocType(null);/* ww w .  ja v a2 s.c  o m*/
    Element root = document.getRootElement();
    // a new root is just added to change the context.
    document.setRootElement(new Element(Q.SEED));
    return new se.miun.itm.input.model.Document(root, dt, document.getBaseURI());
}