* @return {@link Schema} object instance.
* @throws SAXException When a problem with XML data binding occurs.
* @throws IOException When the XML schema file cannot be accessed.
*/
private Schema unmarshalSchema(final String schemaName) throws SAXException, IOException {
Parser parser = null;
InternalContext internalContext = new BackwardCompatibilityContext();
try {
parser = internalContext.getParser();
} catch (RuntimeException rte) {
fail("Can't optain sax parser!");
}
if (parser == null) {
fail("Unable to create SAX parser.");
}
SchemaContext schemaContext = new SchemaContextImpl();
SchemaUnmarshaller schemaUnmarshaller = null;
try {
schemaUnmarshaller = new SchemaUnmarshaller(schemaContext);
} catch (XMLException e) {
fail(e.getMessage());
}
Sax2ComponentReader handler = new Sax2ComponentReader(
schemaUnmarshaller);
parser.setDocumentHandler(handler);
parser.setErrorHandler(handler);
parser.parse(new InputSource(getClass().getResource(schemaName).toExternalForm()));
Schema schema = schemaUnmarshaller.getSchema();
return schema;
}