本来这是件很简单的事情,主要代码如下:
SAXBuilder builder = new SAXBuilder("org.apache.xerces.parsers.SAXParser", true);
// set entity resolver to ignore the DTD specified in the template
builder.setEntityResolver(new EntityResolver() {
public InputSource resolveEntity(String publicId,
String systemId) throws IOException
{
//load schema here
return new InputSource(new FileInputStream(TEMPLATE_SCHEMA_FILE));
}
});
builder.setFeature("http://xml.org/sax/features/validation",true);
builder.setFeature("http://apache.org/xml/features/validation/schema", true);
builder.build(new Byt