SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
schemaFactory.setResourceResolver(new LSResourceResolver() {
@Override
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
if ("http://www.w3.org/2001/XMLSchema.dtd".equals(systemId)) {
ConcreteLSInput concreteLSInput = new ConcreteLSInput();
concreteLSInput.setByteStream(
ClassLoaderUtils.getResourceAsStream("bindings/schemas/XMLSchema.dtd", XMLSecurityConstants.class));
return concreteLSInput;
} else if ("XMLSchema.dtd".equals(systemId)) {
ConcreteLSInput concreteLSInput = new ConcreteLSInput();
concreteLSInput.setByteStream(
ClassLoaderUtils.getResourceAsStream("bindings/schemas/XMLSchema.dtd", XMLSecurityConstants.class));
return concreteLSInput;
} else if ("datatypes.dtd".equals(systemId)) {
ConcreteLSInput concreteLSInput = new ConcreteLSInput();
concreteLSInput.setByteStream(
ClassLoaderUtils.getResourceAsStream("bindings/schemas/datatypes.dtd", XMLSecurityConstants.class));
return concreteLSInput;
} else if ("http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd".equals(systemId)) {
ConcreteLSInput concreteLSInput = new ConcreteLSInput();
concreteLSInput.setByteStream(
ClassLoaderUtils.getResourceAsStream("bindings/schemas/xmldsig-core-schema.xsd", XMLSecurityConstants.class));
return concreteLSInput;
} else if ("http://www.w3.org/2001/xml.xsd".equals(systemId)) {
ConcreteLSInput concreteLSInput = new ConcreteLSInput();
concreteLSInput.setByteStream(
ClassLoaderUtils.getResourceAsStream("bindings/schemas/xml.xsd", XMLSecurityConstants.class));
return concreteLSInput;
}
return null;
}