Package javax.xml.parsers

Examples of javax.xml.parsers.DocumentBuilderFactory


        Dispatch<Source> d = service.createDispatch(new QName("urn:echo:wrapped", "EchoHttpPort"),
                                                    Source.class,
                                                    Service.Mode.PAYLOAD);
        assertNotNull(d);
       
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = dbf.newDocumentBuilder();

        Document document = DOMUtils.readXml(getResourceAsStream("echo-payload.xml"));

        DOMSource source = new DOMSource(document.getDocumentElement());
       
View Full Code Here


        }
       
        @Override
        public void run() {
            try {
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                DocumentBuilder db = dbf.newDocumentBuilder();
                FileInputStream fis = new FileInputStream(file);
                Document document = db.parse(fis);
               
                Element eTop = document.getDocumentElement();
               
View Full Code Here

     * marshaller/unmarshaller instance as the owner of all DOM components.
     *
     * @throws JiBXException on error creating document
     */
    protected DomMapperBase() throws JiBXException {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        try {
            m_document = dbf.newDocumentBuilder().newDocument();
        } catch (ParserConfigurationException e) {
            throw new JiBXException("Unable to create DOM document", e);
        }
    }
View Full Code Here

   * @throws IOException                  if reading from the input stream failed.
   */
  public static Document parseInputStream(final InputStream instream)
      throws ParserConfigurationException, SAXException, IOException
  {
    final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    final DocumentBuilder db = dbf.newDocumentBuilder();
    return db.parse(new InputSource(instream));
  }
View Full Code Here

      fout.write(sqlMappingStr.getBytes());
      fout.flush();
      fout.close();
     
      //修改配置的配置文件,在其中增加sqlMap元素
      DocumentBuilderFactory factory = DocumentBuilderFactory
      .newInstance();
      DocumentBuilder ibatisConfigBuilder = factory.newDocumentBuilder();
      InputStream inputStream = Resources.getResourceAsStream("SqlMapConfig.xml");
      Document doc = ibatisConfigBuilder.parse(inputStream);
     
      NodeList sqlMapElem = doc.getElementsByTagName("sqlMapConfig");
     
View Full Code Here

    /**
     * Constructor.
     */
    public DocumentFormatter() {
        try {
            DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
            m_document = fact.newDocumentBuilder().newDocument();
        } catch (Exception e) {
            throw new RuntimeException("Internal error: unable to create DOM builder", e);
        }
    }
View Full Code Here

        // set class locator
        m_classLocator = new ClassCache.ClassCacheLocator();
        try {
           
            // create the document used for all schemas
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            m_document = dbf.newDocumentBuilder().newDocument();
           
        } catch (ParserConfigurationException e) {
            throw new IllegalStateException("Parser configuration error " +
                e.getMessage());
        } catch (FactoryConfigurationError e) {
View Full Code Here

            throw new IllegalStateException(e);
        }
    }

    private static Document buildDocument(final InputStream is) {
        final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        dbf.setExpandEntityReferences(true);
        final Document doc;
        try {
            DocumentBuilder db = dbf.newDocumentBuilder();
            doc = db.parse(is);
        } catch (Exception e) {
            throw new IllegalStateException("buildDocument failed", e);
        }
        return doc;
View Full Code Here

        }
        return doc;
    }

    private static Document buildFragment(final String frag) {
        final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        dbf.setExpandEntityReferences(true);
        String input = "<doc>" + frag + "</doc>";
        final Document doc;
        try {
            DocumentBuilder db = dbf.newDocumentBuilder();
            doc = db.parse(new ByteArrayInputStream(input.getBytes("UTF-8")));
        } catch (Exception e) {
            throw new IllegalStateException("buildDocument failed", e);
        }
        return doc;
View Full Code Here

        }
        return fields;
    }   
   
    private Document read(File file) throws Exception {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        FileInputStream bis = new FileInputStream(file);
        return db.parse(bis);
    }
View Full Code Here

TOP

Related Classes of javax.xml.parsers.DocumentBuilderFactory

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.