InputStream entityStream) throws IOException {
try {
return new SAXSource(spf.get().newSAXParser().getXMLReader(),
new InputSource(entityStream));
} catch (SAXParseException ex) {
throw new BadRequestException(ex);
} catch (SAXException ex) {
throw new InternalServerErrorException(ex);
} catch (ParserConfigurationException ex) {
throw new InternalServerErrorException(ex);
}