/** * Parses XML from an input source. * * @param source An input source containing valid XML. * @return XML document. * @throws Exception Unspecified exception. */ public static Document parseXMLFromSource(InputSource source) throws Exception { return newDocumentBuilder(false).parse(source); }
/** * Parses XML from an input stream. * * @param stream Input stream containing valid XML. * @return XML document. * @throws Exception Unspecified exception. */ public static Document parseXMLFromStream(InputStream stream) throws Exception { Document document = newDocumentBuilder(false).parse(stream); stream.close(); return document; }
/** * Returns the FSP as an XML document. * * @return The FSP as an XML document. */ public Document getDocument() { if (document == null) { try (InputStream is = stream) { stream = null; document = XMLUtil.newDocumentBuilder(true).parse(is); } catch (Exception e) { throw new ParserException(e, "Exception parsing resource \"%s\"", source); } } return document; }