private Schema resolveLocalSchema(String schemaName, String schemaLanguage) { URL url = classLoaderService.locateResource(schemaName); if (url == null) { throw new XsdException( "Unable to locate schema [" + schemaName + "] via classpath", schemaName); } try { InputStream schemaStream = url.openStream(); try { StreamSource source = new StreamSource(url.openStream()); SchemaFactory schemaFactory = SchemaFactory.newInstance(schemaLanguage); return schemaFactory.newSchema(source); } catch (SAXException e) { throw new XsdException("Unable to load schema [" + schemaName + "]", e, schemaName); } catch (IOException e) { throw new XsdException("Unable to load schema [" + schemaName + "]", e, schemaName); } finally { try { schemaStream.close(); } catch (IOException e) { log.debugf("Problem closing schema stream [%s]", e.toString()); } } } catch (IOException e) { throw new XsdException( "Stream error handling schema url [" + url.toExternalForm() + "]", schemaName); } }
@Override public URL locateResource(String resourceName) { return classLoaderService.locateResource(resourceName); }