[Patch] Patch for javax.xml.parsers.DocumentBuilder
Jeffrey Haškovec
haskovec at gmail.com
Thu Jun 14 16:01:22 UTC 2007
Is it possible to get 2 more parse methods added to DocumentBuilder as
below:
/**
* Parse the content of the given <code>Reader</code> as an XML
* document and return a new DOM {@link Document} object.
* An <code>IllegalArgumentException</code> is thrown if the
* <code>Reader</code> is null.
*
* @param is Reader containing the content to be parsed.
*
* @return <code>Document</code> result of parsing the
* <code>Reader</code>
*
* @throws IOException If any IO errors occur.
* @throws SAXException If any parse errors occur.
* @throws IllegalArgumentException When <code>is</code> is
<code>null</code>
*
* @see org.xml.sax.DocumentHandler
*/
public Document parse(Reader reader)
throws SAXException, IOException {
if (reader == null) {
throw new IllegalArgumentException("Reader cannot be null");
}
InputSource in = new InputSource(reader);
return parse(in);
}
/**
* Parse the content of the given <code>Reader</code> as an
* XML document and return a new DOM {@link Document} object.
* An <code>IllegalArgumentException</code> is thrown if the
* <code>Reader</code> is null.
*
* @param is Reader containing the content to be parsed.
* @param systemId Provide a base for resolving relative URIs.
*
* @return A new DOM Document object.
*
* @throws IOException If any IO errors occur.
* @throws SAXException If any parse errors occur.
* @throws IllegalArgumentException When <code>is</code> is
<code>null</code>
*
* @see org.xml.sax.DocumentHandler
*/
public Document parse(Reader reader, String systemId)
throws SAXException, IOException {
if (reader == null) {
throw new IllegalArgumentException("Reader cannot be null");
}
InputSource in = new InputSource(reader);
in.setSystemId(systemId);
return parse(in);
}
Basically InputSource will already accept a Reader. StringBufferInputStream
is deprecated and says to use StringReader. DocumentBuilder won't parse a
reader, so my problem is I can't parse an XML file that I have as a String
in Memory.
Thanks for your consideration,
Jeffrey Haskovec
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20070614/cbc5988d/attachment.html>
More information about the core-libs-dev
mailing list