code: public static @Nonnull Document parse(@Nonnull Reader stream) throws SAXException, IOException {
          DocumentBuilder docBuilder;
  
          try {
              docBuilder = newDocumentBuilderFactory().newDocumentBuilder();
              docBuilder.setEntityResolver(RestrictiveEntityResolver.INSTANCE);
          } catch (ParserConfigurationException e) {
              throw new IllegalStateException("Unexpected error creating DocumentBuilder.", e);
          }
  
          return docBuilder.parse(new InputSource(stream));
      }
docs: Parse the supplied XML stream data to a {@link Document}.
  <p>
  This function does not close the stream.
  
  @param stream The XML stream.
  @return The XML {@link Document}.
  @throws SAXException Error parsing the XML stream data e.g. badly formed XML.
  @throws IOException Error reading from the steam.
  @since 2.0