• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML schema validation problem

 
Mickey White
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
I have great problems to get a xml document validated against a xml schema. First, I tried using Xerces 2.0.0 beta3, but now i use Xerces 1.4.4. To check my implementation, I use the examples of Xerces (personal-schema.xml, personal.xsd).
I have written the following code:
import org.apache.xerces.parsers.DOMParser;
import org.apache.xerces.framework.*;
import java.io.*;
import org.w3c.dom.Document;
import org.xml.sax.*;
public class Test {
public static void main(String[] args) {
try {
DOMParser parser = new DOMParser();
parser.setFeature( "http://xml.org/sax/features/validation", true);
parser.setFeature( "http://xml.org/sax/features/namespaces", true);

parser.setFeature( "http://apache.org/xml/features/validation/schema", true);
parser.setFeature("http://apache.org/xml/features/validation/dynamic",true);
parser.setValidationSchemaFullChecking(true);
// parser.setFeature( "http://apache.org/xml/features/validation/schema-full-checking", true);

ErrorChecker errors = new ErrorChecker();
parser.setErrorHandler(errors);

System.out.println("Parse Dokument");
parser.parse("personal-schema.xml");

}
catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
}
Now, the code cannot be compiled. It says, the method setValidationSchemaFullChecking is not in class DOMParser. You have to know that DOMParser extends the abstract class XMLParser in another package. This method is protected. But it should be possible to call this message!? Whats the problem with that???

Mickey
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic