Examples of DocumentBuilderFactory


Examples of javax.xml.parsers.DocumentBuilderFactory

        }
        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

Examples of javax.xml.parsers.DocumentBuilderFactory

     * Parses the provided XML byte content.
     * @param xml
     * @throws InvalidModuleXmlException
     */
    private void initialize(byte[] xml) throws InvalidModuleXmlException {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        try {
            DocumentBuilder db = dbf.newDocumentBuilder();
            ByteArrayInputStream bis = new ByteArrayInputStream(xml);
            document = db.parse(bis);
            load();
        } catch(Exception e) {
            throw new InvalidModuleXmlException(getName(), e);
View Full Code Here

Examples of javax.xml.parsers.DocumentBuilderFactory

        W3CDOMStreamReader reader = new W3CDOMStreamReader(doc.getDocumentElement());
        testSingleElement(reader);
    }
   
    private Document getDocument() throws Exception{
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        Document doc = factory.newDocumentBuilder().newDocument();
        return doc;
    }
View Full Code Here

Examples of javax.xml.parsers.DocumentBuilderFactory

   
    public void doDOMRead() throws Exception
    {
        XMLStreamReader reader = ifactory.createXMLStreamReader(getResourceAsStream("amazon2.xml"));
       
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

        dbf.setValidating(false);
        dbf.setIgnoringComments(false);
        dbf.setIgnoringElementContentWhitespace(true);
        dbf.setNamespaceAware(true);
       
        org.w3c.dom.Document doc = STAXUtils.read(dbf.newDocumentBuilder(), reader, false);

//        Diff diff = new Diff(DOMUtils.readXml(getResourceAsStream("amazon2.xml")), doc);
//        assertTrue("XML isn't similar: " + diff.toString(), diff.similar());
//        assertTrue(diff.identical());
    }
View Full Code Here

Examples of javax.xml.parsers.DocumentBuilderFactory

      String xml = "<?xml version='1.0' encoding='ISO-8859-1' ?>\n" +
                   "<xmlBlaster></xmlBlaster>";
      java.io.StringReader reader = new java.io.StringReader(xml);
      org.xml.sax.InputSource input = new org.xml.sax.InputSource(reader);
      try {
         DocumentBuilderFactory dbf = glob.getDocumentBuilderFactory();
         //dbf.setNamespaceAware(true);
         //dbf.setCoalescing(true);
         //dbf.setValidating(false);
         //dbf.setIgnoringComments(true);
         DocumentBuilder db = dbf.newDocumentBuilder ();
         bigDoc = db.parse(input);
      } catch (Exception e) {
         e.printStackTrace();
      }
View Full Code Here

Examples of javax.xml.parsers.DocumentBuilderFactory

   /**
    * Parse the XML encoded SQL statement.
    */
   private Document createDocument() throws Exception
   {
      DocumentBuilderFactory dbf = glob.getDocumentBuilderFactory();
      dbf.setNamespaceAware(true);
      //dbf.setCoalescing(true);
      //dbf.setValidating(false);
      //dbf.setIgnoringComments(true);
      DocumentBuilder db = dbf.newDocumentBuilder();
      if (log.isLoggable(Level.FINE)) log.fine("Tracing " + new String(content));
      ByteArrayInputStream inputStream = new ByteArrayInputStream(content);
      Document doc = db.parse(inputStream);
      return doc;
   }
View Full Code Here

Examples of javax.xml.parsers.DocumentBuilderFactory

    * @param rowsAffected
    * @param descriptor
    */
   private Document createEmptyDocument() throws XmlBlasterException
   {
      DocumentBuilderFactory factory = this.glob.getDocumentBuilderFactory();

      factory.setValidating(false);
      factory.setIgnoringComments(false);
      factory.setNamespaceAware(false);
      try {
         return factory.newDocumentBuilder().newDocument();
      } catch (ParserConfigurationException e) {
         log.severe("Can't create xml document: " + e.toString());
         throw new XmlBlasterException(ME, "Can't create xml document: " + e.toString());
      }
   }
View Full Code Here

Examples of javax.xml.parsers.DocumentBuilderFactory

        assertEquals( "configuration.location", "", configuration.getLocation() );
    }

    private Document createDocument() throws ParserConfigurationException
    {
        final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        final DocumentBuilder builder = factory.newDocumentBuilder();
        return builder.newDocument();
    }
View Full Code Here

Examples of javax.xml.parsers.DocumentBuilderFactory

     */
    public static Element toElement( final Configuration configuration )
    {
        try
        {
            final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            final DocumentBuilder builder = factory.newDocumentBuilder();
            final Document document = builder.newDocument();

            return createElement( document, configuration );
        }
        catch( final Throwable t )
View Full Code Here

Examples of javax.xml.parsers.DocumentBuilderFactory

        ResourceLocator rl = new ResourceLocator();
        InputStream is = rl.findResource(fileName);
        if ( is == null ) {
            throw new ReaderException("the file "+fileName+" cannot be found in the classpath");
        }
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setValidating(false);
        DocumentBuilder db = null;
        try {
            db = dbf.newDocumentBuilder();
        } catch (ParserConfigurationException pce) {
            ErrorHandler.reportError("Exception during parser configuration",pce);
            throw new ReaderException("Exception during parser configuration:" + pce.getMessage());
        }
        Document doc = null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.