public Document parse(final InputSource source, final ErrorHandler errorhandler, final EntityResolver entityResolver) throws DOMParserException { DocumentBuilder pooledDocumentBuilder = m_documentBuilderPool.acquire(m_domParserOptions); try { pooledDocumentBuilder.setEntityResolver(entityResolver); pooledDocumentBuilder.setErrorHandler(errorhandler); return pooledDocumentBuilder.parse(source); } catch (Exception ex) { throw new DOMParserException("unexpected exception during parsing", ex); } finally { m_documentBuilderPool.release(pooledDocumentBuilder, m_domParserOptions); } } }
public static Document createEmptyDocument(final DOMParserOptions options) { DOMParserOptions opts = options != null ? options : DOMParserOptions.getDefault(); DocumentBuilderPool pool = getDocumentBuilderPool(); DocumentBuilder builder = pool.acquire(opts); try { return builder.newDocument(); } finally { pool.release(builder, opts); } }