use of org.apache.xerces.parsers.DOMParser in project openj9 by eclipse.
the class HookTool method parseFile.
private void parseFile() throws IOException {
if (VERBOSE) {
System.out.println("Generating hook files for " + xmlFile.getPath());
}
DOMParser parser = new DOMParser();
try {
parser.parse(xmlFile.toURI().toURL().toExternalForm());
} catch (SAXException se) {
se.printStackTrace();
System.exit(-1);
}
Document document = parser.getDocument();
Element interfaceNode = document.getDocumentElement();
Node publicHeaderNode = getNamedChild(interfaceNode, "publicHeader");
Node privateHeaderNode = getNamedChild(interfaceNode, "privateHeader");
Node struct = getNamedChild(interfaceNode, "struct");
Node declarations = getNamedChild(interfaceNode, "declarations");
createPublicHeader(getText(publicHeaderNode), declarations == null ? null : getText(declarations));
createPrivateHeader(getText(privateHeaderNode));
NodeList children = interfaceNode.getElementsByTagName("event");
for (int i = 0, n = children.getLength(); i < n; ++i) {
addEvent((Element) children.item(i));
}
closePublicHeader();
closePrivateHeader(struct);
}
use of org.apache.xerces.parsers.DOMParser in project kie-wb-common by kiegroup.
the class FormSerializationManagerImpl method loadFormFromXML.
@Override
public Form loadFormFromXML(String xml) throws Exception {
if (StringUtils.isBlank(xml)) {
return null;
}
DOMParser parser = new DOMParser();
parser.parse(new InputSource(new StringReader(xml)));
Document doc = parser.getDocument();
NodeList nodes = doc.getElementsByTagName(NODE_FORM);
Node rootNode = nodes.item(0);
return deserializeForm(rootNode);
}
use of org.apache.xerces.parsers.DOMParser in project mondrian by pentaho.
the class XmlUtil method parse.
/**
* Parse a stream into a Document (no validation).
*/
public static Document parse(InputStream in) throws SAXException, IOException {
InputSource source = new InputSource(in);
DOMParser parser = XmlUtil.getParser(null, null, false);
try {
parser.parse(source);
checkForParseError(parser);
} catch (SAXParseException ex) {
checkForParseError(parser, ex);
}
Document document = parser.getDocument();
return document;
}
use of org.apache.xerces.parsers.DOMParser in project mondrian by pentaho.
the class XmlUtil method validate.
public static void validate(String docStr, String schemaLocationPropertyValue, EntityResolver resolver) throws IOException, SAXException {
if (resolver == null) {
resolver = new Resolver();
}
DOMParser parser = getParser(schemaLocationPropertyValue, resolver, true);
try {
parser.parse(new InputSource(new StringReader(docStr)));
checkForParseError(parser);
} catch (SAXParseException ex) {
checkForParseError(parser, ex);
}
}
use of org.apache.xerces.parsers.DOMParser in project wildfly by wildfly.
the class XercesUsageWebService method parseUsingXerces.
@Override
public String parseUsingXerces(String xmlResource) {
final InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(xmlResource);
if (inputStream == null) {
throw new RuntimeException(xmlResource + " could not be found");
}
DOMParser domParser = new DOMParser();
try {
domParser.parse(new InputSource(inputStream));
return SUCCESS_MESSAGE;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations