code: private Document getDOMObject(InputStream is, boolean validating)
        throws SAXException, IOException, ParserConfigurationException {
  
      // Create a builder factory
  
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      if (!validating) {
        factory.setValidating(validating);
        factory.setSchema(null);
        factory.setNamespaceAware(false);
      }
  
      DocumentBuilder builder = factory.newDocumentBuilder();
      // Create the builder and parse the file
      Document doc = builder.parse(is);
      return doc;
    }
docs: Parse an {@link InputStream} containing an XML document, into a DOM object.
  
  @param is
  An {@link InputStream} representing an xml file.
  @param validating
  True iff validating should be turned on.
  @return A DOM Object containing a parsed XML document or a null value if
  there is an error in parsing.
  @throws ParserConfigurationException
  @throws IOException
  @throws SAXException