Here is my snippet:
public static SAXBuilder createBuilder(@NotNull final String schemaPath) {
final SAXBuilder builder = new SAXBuilder("com.sun.org.apache.xerces.internal.parsers.SAXParser", true);
builder.setFeature("http://apache.org/xml/features/validation/schema", true);
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
builder.setFeature("http://apache.org/xml/features/disallow-doctype-decl",true);
builder.setFeature("http://xml.org/sax/features/external-general-entities", false);
builder.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
builder.setExpandEntities(false);
builder.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", schemaPath);
builder.setEntityResolver(getEntityResolver());
return builder;
}
I have spent some time searching, but there's not much left out there
I identified the root cause of this problem. It was because of processContents="lax"
attribute in my xsd