Search in sources :

Example 1 with XMLReaderJDOMFactory

use of org.jdom2.input.sax.XMLReaderJDOMFactory in project archi by archimatetool.

the class JDOMUtils method readXMLFile.

/**
 * Reads and returns a JDOM Document from file with Schema validation
 * @param xmlFile The XML File
 * @param schemaFile One or more Schema files
 * @return The JDOM Document or null if not found
 * @throws JDOMException
 * @throws IOException
 */
public static Document readXMLFile(File xmlFile, File... schemaFiles) throws IOException, JDOMException {
    XMLReaderJDOMFactory factory = new XMLReaderXSDFactory(schemaFiles);
    SAXBuilder builder = new SAXBuilder(factory);
    // This allows UNC mapped locations to load
    return builder.build(new FileInputStream(xmlFile));
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) XMLReaderXSDFactory(org.jdom2.input.sax.XMLReaderXSDFactory) XMLReaderJDOMFactory(org.jdom2.input.sax.XMLReaderJDOMFactory) FileInputStream(java.io.FileInputStream)

Aggregations

FileInputStream (java.io.FileInputStream)1 SAXBuilder (org.jdom2.input.SAXBuilder)1 XMLReaderJDOMFactory (org.jdom2.input.sax.XMLReaderJDOMFactory)1 XMLReaderXSDFactory (org.jdom2.input.sax.XMLReaderXSDFactory)1