public void parse(InputSource input)
throws SAXException
{
mScanner = null;
String systemId = input.getSystemId();
ReaderConfig cfg = mConfig;
URL srcUrl = null;
// Let's figure out input, first, before sending start-doc event
InputStream is = null;
Reader r = input.getCharacterStream();
if (r == null) {
is = input.getByteStream();
if (is == null) {
if (systemId == null) {
throw new SAXException("Invalid InputSource passed: neither character or byte stream passed, nor system id specified");
}
try {
srcUrl = URLUtil.urlFromSystemId(systemId);
is = URLUtil.optimizedStreamFromURL(srcUrl);
} catch (IOException ioe) {
SAXException saxe = new SAXException(ioe);
saxe.initCause(ioe);
throw saxe;
}
}
}
if (mContentHandler != null) {
mContentHandler.setDocumentLocator(this);
mContentHandler.startDocument();
}
try {
InputBootstrapper bs;
String inputEnc = input.getEncoding();
String publicId = input.getPublicId();
if (r != null) {
bs = ReaderBootstrapper.getInstance(r, publicId, systemId, inputEnc);
} else {
bs = StreamBootstrapper.getInstance(is, publicId, systemId);
}
/* Note: since we are reusing the same config instance, need to
* make sure state is not carried forward. Thus:
*/
cfg.resetState();
// false -> not for event reader; false -> no auto-closing
mScanner = (BasicStreamReader) mStaxFactory.createSR(cfg, systemId, bs, false, false);
// Need to get xml declaration stuff out now:
{