It worked. I registered my schema so that the parser always use that. Here is my code:
parser.setEntityResolver( new EntityResolver() {
public InputSource resolveEntity(
String publicId, String systemId) {
// use the default behaviour
return new InputSource( schemaURL );
}});
I have another problem though. If my xml file doesn't include any schema reference, it is just a well formed xml. It looks like the parser can't find the root element.
The error message is(assume book is the root element):
org.xml.sax.SAXParseException: Element type "Book" must be declared.
my xml file is like this:
<?xml version="1.0"?>
<Book>
<Author>OO</Author>
</Book>