• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML schema validation problem

Mickey White
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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/schema-full-checking", true);

ErrorChecker errors = new ErrorChecker();

System.out.println("Parse Dokument");

catch (Exception e) {
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???

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic