Package javax.xml.parsers

Examples of javax.xml.parsers.DocumentBuilderFactory


   * @param map  The map containing the updates.
   * @exception Exception  unspecialized error
   */
  public String update(InputStream in, Map map) throws Exception {
    this.map = map;
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    Document doc = docBuilder.parse(in);

    NodeList nl = doc.getElementsByTagName("resourceadapter");
    for (int i = 0; i < nl.getLength(); i++) {
      Node node = nl.item(i);
View Full Code Here


     * @throws IOException
     * @throws SAXException
     */
  public XmpReader(byte[] bytes) throws SAXException, IOException {
    try {
          DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
          fact.setNamespaceAware(true);
      DocumentBuilder db = fact.newDocumentBuilder();
          ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
          domDocument = db.parse(bais);
    } catch (ParserConfigurationException e) {
      throw new ExceptionConverter(e);
    }
View Full Code Here

            public void abortWorkItem(WorkItem manager, WorkItemManager mgr) {
               
            }

            public void executeWorkItem(WorkItem workItem, WorkItemManager mgr) {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder;
        try {
          builder = factory.newDocumentBuilder();
        } catch (ParserConfigurationException e) {
          // TODO Auto-generated catch block
//          e.printStackTrace();
          throw new RuntimeException(e);
        }
View Full Code Here

      return configs_.values();
   }

   private void parseConfiguration(InputStream is) throws Exception
   {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      factory.setIgnoringComments(true);
      factory.setCoalescing(true);
      factory.setNamespaceAware(false);
      factory.setValidating(false);
      DocumentBuilder parser = factory.newDocumentBuilder();
      Document document = parser.parse(is);
      NodeList nodes = document.getElementsByTagName("locale-config");
      for (int i = 0; i < nodes.getLength(); i++)
      {
         Node node = nodes.item(i);
View Full Code Here

    private List<ResultGeoCodeApi> parseResults(String xml){
        List<ResultGeoCodeApi> results = new ArrayList<ResultGeoCodeApi>();
        try {
           
            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
            Document doc = docBuilder.parse(new ByteArrayInputStream(xml.getBytes()));
              // normalize text representation
            doc.getDocumentElement ().normalize ();
            NodeList listOfResults = doc.getElementsByTagName("Result");
            for(int i= 0; i< listOfResults.getLength(); i++){
View Full Code Here

    }

    private static DocumentBuilder createDocumentBuilder()
        throws ParserConfigurationException {

        DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = fact.newDocumentBuilder();

        builder.setErrorHandler( null );
       
        return builder;
    }
View Full Code Here

  private XMLParserFactory() {
  }

  public DocumentBuilder createParser() {
    DocumentBuilderFactory factory = createDocumentBuilderFactory();
    try {
      return createDocumentBuilder(factory);
    } catch (ParserConfigurationException e) {
      throw new MappingException("Failed to create XML Parser !", e);
    }
View Full Code Here

   * @return the JAXP DocumentBuilderFactory
   * @throws javax.xml.parsers.ParserConfigurationException
   *          if thrown by JAXP methods
   */
  private DocumentBuilderFactory createDocumentBuilderFactory() {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setValidating(true);
    factory.setNamespaceAware(true);
    factory.setIgnoringElementContentWhitespace(true);
    factory.setAttribute(SCHEMA_FEATURE, true); // For Xerces implementation
    return factory;
  }
View Full Code Here

        else if (xfa instanceof PRStream) {
            byte[] b = PdfReader.getStreamBytes((PRStream)xfa);
            bout.write(b);
        }
        bout.close();
        DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
        fact.setNamespaceAware(true);
        DocumentBuilder db = fact.newDocumentBuilder();
        domDocument = db.parse(new ByteArrayInputStream(bout.toByteArray()));  
        Node n = domDocument.getFirstChild();
        while (n.getChildNodes().getLength() == 0) {
          n = n.getNextSibling();
        }
View Full Code Here

        Document expectedDoc = buildDocument(new ByteArrayInputStream(expected.getBytes("UTF-8")));
        XMLAssert.assertXMLEqual(expectedDoc, actualDoc);
    }

    private static Document buildDocument(InputStream is) {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        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

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.