// under the multi-thread environment, more than once s4s could be loaded.
// it's a waste of resource, but by no means fatal.
if(xmlSchema4XmlSchema==null) {
try {
XSFactoryImpl factory = new XSFactoryImpl();
factory.setEntityResolver( new EntityResolver() {
public InputSource resolveEntity( String publicId, String systemId ) {
if(systemId.endsWith("datatypes.xsd"))
return new InputSource(XMLSchemaReader.class.getResourceAsStream(
"datatypes.xsd"));
if(systemId.endsWith("xml.xsd"))
return new InputSource(XMLSchemaReader.class.getResourceAsStream(
"xml.xsd"));
System.out.println("unexpected system ID: "+systemId);
return null;
}
});
xmlSchema4XmlSchema = factory.compileSchema(
XMLSchemaReader.class.getResourceAsStream("xmlschema.xsd"));
} catch( Exception e ) {
e.printStackTrace();
throw new Error("unable to load schema-for-schema for W3C XML Schema");
}