Search in sources :

Example 26 with Document

use of org.dom4j.Document in project gradle by gradle.

the class DOM4JSerializer method readSettingsFile.

public static DOM4JSettingsNode readSettingsFile(ImportInteraction importInteraction, FileFilter fileFilter) {
    File file = importInteraction.promptForFile(fileFilter);
    if (file == null) {
        return null;
    }
    if (!file.exists()) {
        importInteraction.reportError("File does not exist: " + file.getAbsolutePath());
        //we should really sit in a loop until they cancel or give us a valid file.
        return null;
    }
    try {
        SAXReader reader = new SAXReader();
        Document document = reader.read(file);
        return new DOM4JSettingsNode(document.getRootElement());
    } catch (Throwable t) {
        LOGGER.error("Unable to read file: " + file.getAbsolutePath(), t);
        importInteraction.reportError("Unable to read file: " + file.getAbsolutePath());
        return null;
    }
}
Also used : SAXReader(org.dom4j.io.SAXReader) Document(org.dom4j.Document) DOM4JSettingsNode(org.gradle.gradleplugin.foundation.settings.DOM4JSettingsNode)

Example 27 with Document

use of org.dom4j.Document in project gradle by gradle.

the class DOM4JSerializer method createBlankSettings.

public static DOM4JSettingsNode createBlankSettings() {
    Document document = DocumentHelper.createDocument();
    Element rootElement = document.addElement("root");
    DOM4JSettingsNode settings = new DOM4JSettingsNode(rootElement);
    return settings;
}
Also used : Element(org.dom4j.Element) Document(org.dom4j.Document) DOM4JSettingsNode(org.gradle.gradleplugin.foundation.settings.DOM4JSettingsNode)

Example 28 with Document

use of org.dom4j.Document in project JessMA by ldcsaa.

the class DruidSessionMgr method loadXmlCfg.

@SuppressWarnings("unchecked")
private void loadXmlCfg(Properties props) throws Exception {
    SAXReader sr = new SAXReader();
    Document doc = sr.read(new File(configFile));
    Element root = doc.getRootElement();
    List<Element> list = root.elements("property");
    for (Element e : list) {
        String key = e.attributeValue("name");
        String value = e.getTextTrim();
        props.put(key, value);
    }
}
Also used : SAXReader(org.dom4j.io.SAXReader) Element(org.dom4j.Element) Document(org.dom4j.Document) File(java.io.File)

Example 29 with Document

use of org.dom4j.Document in project JessMA by ldcsaa.

the class AppConfig method getRootElement.

private Element getRootElement() throws DocumentException {
    SAXReader sr = new SAXReader();
    Document doc = sr.read(new File(confFile));
    Element root = doc.getRootElement();
    return root;
}
Also used : SAXReader(org.dom4j.io.SAXReader) Element(org.dom4j.Element) Document(org.dom4j.Document) File(java.io.File)

Example 30 with Document

use of org.dom4j.Document in project cuba by cuba-platform.

the class XMLConverter2 method _process.

protected Document _process(Entity entity, View view) throws Exception {
    Document document = DocumentHelper.createDocument();
    Element rootEl = document.addElement("instances");
    encodeEntity(entity, new HashSet<Entity>(), view, rootEl);
    return document;
}
Also used : BaseGenericIdEntity(com.haulmont.cuba.core.entity.BaseGenericIdEntity) Entity(com.haulmont.cuba.core.entity.Entity) Element(org.dom4j.Element) Document(org.dom4j.Document)

Aggregations

Document (org.dom4j.Document)891 Element (org.dom4j.Element)492 SAXReader (org.dom4j.io.SAXReader)252 File (java.io.File)135 IOException (java.io.IOException)135 StringReader (java.io.StringReader)111 ArrayList (java.util.ArrayList)110 List (java.util.List)107 Test (org.junit.Test)101 DocumentException (org.dom4j.DocumentException)93 HashMap (java.util.HashMap)90 InputStream (java.io.InputStream)82 Node (org.dom4j.Node)80 Test (org.junit.jupiter.api.Test)80 XMLWriter (org.dom4j.io.XMLWriter)53 ReturnedDocument (org.collectionspace.chain.csp.persistence.services.connection.ReturnedDocument)48 FileInputStream (java.io.FileInputStream)45 Map (java.util.Map)41 ReturnedMultipartDocument (org.collectionspace.chain.csp.persistence.services.connection.ReturnedMultipartDocument)40 XMLParser (org.olat.core.util.xml.XMLParser)40