use of org.jdom2.located.LocatedJDOMFactory in project mule-migration-assistant by mulesoft.
the class XmlDslUtils method generateDocument.
/**
* Return JDOM document from a file path.
*
* @param filePath the path of the file
* @return the jdom document.
*/
public static Document generateDocument(Path filePath) throws JDOMException, IOException {
SAXBuilder saxBuilder = new SAXBuilder();
saxBuilder.setJDOMFactory(new LocatedJDOMFactory());
return saxBuilder.build(filePath.toFile());
}
use of org.jdom2.located.LocatedJDOMFactory in project qpp-conversion-tool by CMSgov.
the class XmlUtils method parseXmlStream.
/**
* Parses a stream of XML into a tree of XML elements.
*
* @param xmlStream The XML.
* @return The root element of the XML tree.
* @throws XmlException When a failure to parse the XML.
*/
public static Element parseXmlStream(InputStream xmlStream) {
try {
SAXBuilder saxBuilder = new SAXBuilder();
saxBuilder.setFeature(DISALLOW_DTD, true);
saxBuilder.setFeature(EXT_GENERAL_ENTITIES, false);
saxBuilder.setFeature(EXT_PARAM_ENTITIES, false);
saxBuilder.setJDOMFactory(new LocatedJDOMFactory());
return saxBuilder.build(xmlStream).getRootElement();
} catch (JDOMException | IOException e) {
throw new XmlException("Failed to process XML String into DOM Element", e);
}
}
use of org.jdom2.located.LocatedJDOMFactory in project jts by locationtech.
the class TestReader method createTestRun.
public TestRun createTestRun(File testFile, int runIndex) {
try {
SAXBuilder builder = new SAXBuilder();
builder.setJDOMFactory(new LocatedJDOMFactory());
Document document = builder.build(new FileInputStream(testFile));
Element runElement = document.getRootElement();
if (!runElement.getName().equalsIgnoreCase("run")) {
throw new TestParseException("Expected <run> but encountered <" + runElement.getName() + ">");
}
return parseTestRun(runElement, testFile, runIndex);
} catch (Exception e) {
parsingProblems.add("An exception occurred while parsing " + testFile + ": " + e.toString());
return null;
}
}
use of org.jdom2.located.LocatedJDOMFactory in project mule-migration-assistant by mulesoft.
the class ReportEntryModel method setElementLocation.
public void setElementLocation() throws Exception {
try {
SAXBuilder saxBuilder = new SAXBuilder();
saxBuilder.setJDOMFactory(new LocatedJDOMFactory());
if (filePath != null) {
Document document = saxBuilder.build(Paths.get(filePath).toFile());
setElementLocation(document);
}
} catch (Exception ex) {
throw new MigrationJobException("Failed to obtain new element location.", ex);
}
}
Aggregations