code: private static Document parseDocument(final InputStream is) throws InvalidConfigurationException
      {
          Document persistenceXmlDoc;
          final List parsingErrors = new ArrayList();
          final InputSource source = new InputSource(is);
          final DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
          docBuilderFactory.setNamespaceAware(true);
  
          try
          {
              DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
              docBuilder.setErrorHandler(new ErrorLogger("XML InputStream", parsingErrors));
              persistenceXmlDoc = docBuilder.parse(source);
          }
          catch (ParserConfigurationException e)
          {
              log.error("Error during parsing, Caused by: {}.", e);
              throw new PersistenceLoaderException("Error during parsing persistence.xml, caused by: ", e);
          }
          catch (IOException e)
          {
              throw new InvalidConfigurationException("Error reading persistence.xml, caused by: ", e);
          }
          catch (SAXException e)
          {
              throw new InvalidConfigurationException("Error parsing persistence.xml, caused by: ", e);
          }
  
          if (!parsingErrors.isEmpty())
          {
              throw new InvalidConfigurationException("Invalid persistence.xml", (Throwable) parsingErrors.get(0));
          }
  
          return persistenceXmlDoc;
      }
docs: Reads the content of the persistence.xml file into an object model, with
  the root node of type {@link Document}.
  
  @param is
  {@link InputStream} of the persistence.xml content
  @return root node of the parsed xml content
  @throws InvalidConfigurationException
  if the content could not be read due to an I/O error or could
  not be parsedÏ