}
try {
parser.setFeature("http://xml.org/sax/features/namespaces", true);
} catch (SAXNotSupportedException err) { // SAX2 parsers MUST support this feature!
throw new DynamicError(
"The SAX2 parser does not recognize the 'namespaces' feature");
} catch (SAXNotRecognizedException err) {
throw new DynamicError(
"The SAX2 parser does not support setting the 'namespaces' feature to true");
}
try {
parser.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
} catch (SAXNotSupportedException err) { // SAX2 parsers MUST support this feature!
throw new DynamicError(
"The SAX2 parser does not recognize the 'namespace-prefixes' feature");
} catch (SAXNotRecognizedException err) {
throw new DynamicError(
"The SAX2 parser does not support setting the 'namespace-prefixes' feature to false");
}
if ((validation & Validation.VALIDATION_MODE_MASK) != Validation.PRESERVE) {
// Add a document validator to the pipeline
receiver = config.getDocumentValidator(receiver,
source.getSystemId(),
config.getNamePool(),
validation);
}
ReceivingContentHandler ce = new ReceivingContentHandler();
ce.setReceiver(receiver);
ce.setConfiguration(config);
parser.setContentHandler(ce);
parser.setDTDHandler(ce);
try {
parser.setProperty("http://xml.org/sax/properties/lexical-handler", ce);
} catch (SAXNotSupportedException err) { // this just means we won't see the comments
} catch (SAXNotRecognizedException err) {
}
try {
parser.parse(source.getInputSource());
} catch (SAXException err) {
Exception nested = err.getException();
if (nested instanceof XPathException) {
throw (XPathException)nested;
} else {
throw new DynamicError(err);
}
} catch (java.io.IOException err) {
throw new DynamicError(err);
}
}