Code example for DocumentBuilder

Methods: parsesetEntityResolversetErrorHandler

0
    dbf.setValidating(false);
 
    try 
    { 
      final DocumentBuilder db = dbf.newDocumentBuilder();
      db.setEntityResolver(ParserEntityResolver.getDefaultResolver());
      db.setErrorHandler(new LoggingErrorHandler());
      final ResourceDataInputSource input = new ResourceDataInputSource(data, manager);
      return new DomResource(data.getKey(), db.parse(input), data.getVersion(manager));
    } 
    catch (ParserConfigurationException e)
    { 
      throw new ResourceCreationException("Unable to initialize the XML-Parser", e);
    } 
    catch (SAXException e)
    { 
      throw new ResourceCreationException("Unable to parse the document: " + data.getKey(), e);
    } 
    catch (IOException e)
    { 
      throw new ResourceLoadingException("Unable to read the stream from document: " + data.getKey(), e);