You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Cirip Tomas <to...@theIMO.com> on 2002/04/26 18:24:31 UTC

SAX parser - validation against XML Schema - Writer example

Hi,

I am trying to validate XML against XML schema using SAX Parser and somehow
it dosn't work for me. I've tried sax.Writer example and it doesn't bring me
an error even though there is an error in xml file(verified with XML Spy)
and I've specified to validate against schema both -s and -v parameters.
Does anybody have a clue what can be wrong?

When I use following code:

      XMLReader saxParser =
 
XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");

      saxParser.setFeature("http://xml.org/sax/features/validation", true);
 
saxParser.setFeature("http://apache.org/xml/features/validation/schema",
true);
      saxParser.setFeature("http://xml.org/sax/features/namespace-prefixes",
true);
      saxParser.setFeature("http://xml.org/sax/features/namespaces", true);
      saxParser.setErrorHandler(handler);
      saxParser.parse(filename);

I get error:

[error] cvc-elt.1: Cannot find the declaration of element 'Invoice'.

Is it trying to use missing DTD for a validation instead of XML Schema? 

Thank you

Tomas

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org