Package com.sun.org.apache.xerces.internal.parsers

Examples of com.sun.org.apache.xerces.internal.parsers.DOMParser


        return;
    }
   
    private Document createPropertiesDocument(byte[] input) throws Exception {
        ByteArrayInputStream ba = new ByteArrayInputStream(input);
        DOMParser dp = new DOMParser();

        dp.setFeature("http://xml.org/sax/features/validation", false);
        dp.setFeature(
                "http://xml.org/sax/features/external-parameter-entities",
                false);
        dp.setFeature("http://xml.org/sax/features/namespaces", false);
        dp
                .setFeature(
                        "http://apache.org/xml/features/nonvalidating/load-external-dtd",
                        false);

        dp.parse(new InputSource(ba));
        return dp.getDocument();
    }
View Full Code Here


            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
            return documentBuilder.parse(file);
        } catch (ParserConfigurationException | IOException e) {
            logger.error("Exception while parsing file {}:", file, e);
        }
        return new DOMParser().getDocument();
    }
View Full Code Here

    return new ConfigUrlBuilder(linkPrefix, linkSuffix);
  }

  public Set<String> getExcludedTerms() throws Exception {
    Set<String> terms = new HashSet<String>();
    DOMParser parser = new DOMParser();
    parser.parse(getExcludedTermsFilename());
    DocumentImpl document = (DocumentImpl)parser.getDocument();
    javax.xml.xpath.XPath xpath = XPathFactory.newInstance().newXPath();
    XPathExpression expr = xpath.compile("/exclude/term/text()");
      Object result = expr.evaluate(document, XPathConstants.NODESET);
      NodeList nodes = (NodeList) result;
      for (int i = 0; i < nodes.getLength(); i++) {
View Full Code Here

    DNVGraph g = new DNVGraph();

    // TODO Auto-generated method stub
    try
    {
      DOMParser parser = new DOMParser();
      parser.parse( filetoparse );
      Document doc = parser.getDocument();

      NodeList nodes = doc.getElementsByTagName( "object" );
      System.out.println( "There are " + nodes.getLength() + "  nodes." );
      NodeList nl = doc.getElementsByTagName( "*" );
      Node n;
View Full Code Here

            if (val != null) {
                return val;
            }
        }

        DOMParser domParser = null;
        try {
            // We create a dummy DocumentBuilderImpl in case the attribute
            // name is not one that is in the attributes hashtable.
            domParser =
                new DocumentBuilderImpl(this, attributes, features).getDOMParser();
            return domParser.getProperty(name);
        } catch (SAXException se1) {
            // assert(name is not recognized or not supported), try feature
            try {
                boolean result = domParser.getFeature(name);
                // Must have been a feature
                return result ? Boolean.TRUE : Boolean.FALSE;
            } catch (SAXException se2) {
                // Not a property or a feature
                throw new IllegalArgumentException(se1.getMessage());
View Full Code Here

            if (val != null) {
                return ((Boolean) val).booleanValue();
            }
        }
        try {
            DOMParser domParser = new DocumentBuilderImpl(this, attributes, features).getDOMParser();
            return domParser.getFeature(name);
        }
        catch (SAXException e) {
            throw new ParserConfigurationException(e.getMessage());
        }
    }
View Full Code Here

        // note that this should never produce errors or require
        // entity resolution, so just a barebones configuration with
        // a couple of feature  set will do fine
        config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, true);
        config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE, false);
        fDOMParser = new DOMParser(config);
        return fDOMParser;
    }
View Full Code Here

    }

    DocumentBuilderImpl(DocumentBuilderFactoryImpl dbf, Hashtable dbfAttrs, Hashtable features, boolean secureProcessing)
        throws SAXNotRecognizedException, SAXNotSupportedException
    {
        domParser = new DOMParser();

        // If validating, provide a default ErrorHandler that prints
        // validation errors with a warning telling the user to set an
        // ErrorHandler
        if (dbf.isValidating()) {
View Full Code Here

    // this creates the new Annotation element as the first child
    // of the Node
    private synchronized void writeToDOM(Node target, short type){
        Document futureOwner = (type == XSAnnotation.W3C_DOM_ELEMENT)?target.getOwnerDocument():(Document)target;
        DOMParser parser = fGrammar.getDOMParser();
        StringReader aReader = new StringReader(fData);
        InputSource aSource = new InputSource(aReader);
        try {
            parser.parse(aSource);
        } catch (SAXException e) {
            // this should never happen!
            // REVISIT:  what to do with this?; should really not
            // eat it...
        } catch (IOException i) {
            // ditto with above
        }
        Document aDocument = parser.getDocument();
        Element annotation = aDocument.getDocumentElement();
        Node newElem = futureOwner.importNode(annotation, true);
        target.insertBefore(newElem, target.getFirstChild());
    }
View Full Code Here

    // this creates the new Annotation element as the first child
    // of the Node
    private synchronized void writeToDOM(Node target, short type) {
        Document futureOwner = (type == XSAnnotation.W3C_DOM_ELEMENT) ?
                target.getOwnerDocument() : (Document)target;
        DOMParser parser = fGrammar.getDOMParser();
        StringReader aReader = new StringReader(fData);
        InputSource aSource = new InputSource(aReader);
        try {
            parser.parse(aSource);
        }
        catch (SAXException e) {
            // this should never happen!
            // REVISIT:  what to do with this?; should really not
            // eat it...
        }
        catch (IOException i) {
            // ditto with above
        }
        Document aDocument = parser.getDocument();
        parser.dropDocumentReferences();
        Element annotation = aDocument.getDocumentElement();
        Node newElem = null;
        if (futureOwner instanceof CoreDocumentImpl) {
            newElem = futureOwner.adoptNode(annotation);
            // adoptNode will return null when the DOM implementations are not compatible.
View Full Code Here

TOP

Related Classes of com.sun.org.apache.xerces.internal.parsers.DOMParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.