Search in sources :

Example 16 with DOMParser

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);
}
Also used : Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) DOMParser(org.apache.xerces.parsers.DOMParser) Document(org.w3c.dom.Document) SAXException(org.xml.sax.SAXException)

Example 17 with DOMParser

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);
}
Also used : InputSource(org.xml.sax.InputSource) NodeList(org.w3c.dom.NodeList) XMLNode(org.kie.workbench.common.forms.migration.legacy.services.impl.util.XMLNode) Node(org.w3c.dom.Node) StringReader(java.io.StringReader) DOMParser(org.apache.xerces.parsers.DOMParser) Document(org.w3c.dom.Document)

Example 18 with DOMParser

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;
}
Also used : DOMParser(org.apache.xerces.parsers.DOMParser)

Example 19 with DOMParser

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);
    }
}
Also used : DOMParser(org.apache.xerces.parsers.DOMParser)

Example 20 with DOMParser

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);
    }
}
Also used : InputSource(org.xml.sax.InputSource) InputStream(java.io.InputStream) DOMParser(org.apache.xerces.parsers.DOMParser)

Aggregations

DOMParser (org.apache.xerces.parsers.DOMParser)25 InputSource (org.xml.sax.InputSource)14 Node (org.w3c.dom.Node)10 Document (org.w3c.dom.Document)9 StringReader (java.io.StringReader)5 Element (org.w3c.dom.Element)5 NodeList (org.w3c.dom.NodeList)5 SAXException (org.xml.sax.SAXException)5 IOException (java.io.IOException)4 HTMLConfiguration (org.cyberneko.html.HTMLConfiguration)4 ArrayList (java.util.ArrayList)3 HtmlMaterial (fi.otavanopisto.muikku.plugins.material.model.HtmlMaterial)2 WorkspaceMaterial (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial)2 WorkspaceNode (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceNode)2 FileNotFoundException (java.io.FileNotFoundException)2 Transformer (javax.xml.transform.Transformer)2 XIncludeParserConfiguration (org.apache.xerces.parsers.XIncludeParserConfiguration)2 DTDConfiguration (org.cyberneko.dtd.DTDConfiguration)2 NamedNodeMap (org.w3c.dom.NamedNodeMap)2 AcsFileFinder (alma.acs.makesupport.AcsFileFinder)1