deserialize(document);
Source src = new DOMSource(document);
src.setSystemId(is.getSystemId());
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
final LSResourceResolver oldResolver = factory.getResourceResolver();
LSResourceResolver resolver = new LSResourceResolver() {
public LSInput resolveResource(String type, String nsURI,
String publicId, String systemId, String baseURI) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("resolving resource type: " + type + "\n"
+ " namespaceURI:" + nsURI + "\n"
+ " publicId:" + publicId + "\n"
+ " systemId:" + systemId + "\n"
+ " baseURI:" + baseURI);
}
if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(type)) {
LSInput lsi = new SchemaInput(type, nsURI, publicId, systemId, baseURI);
String resourceName = systemId;
InputSource src = getSchemaInputSource(baseURI, resourceName);
lsi.setByteStream(src.getByteStream());
lsi.setSystemId(src.getSystemId());
return lsi;
}
return oldResolver == null ? null
: oldResolver.resolveResource(type, nsURI, publicId, systemId, baseURI);
}
};
factory.setResourceResolver(resolver);
try {
schema = factory.newSchema(src);
} catch (SAXException ex) {
throw new ConfigurationException(new Message("SCHEMA_CREATION_ERROR_EXC", LOG, location), ex);
}
document = null;