Validating Schemas With Xerces

All over the web I have seen rumors that claim that one can validate schemas
with Xerces-J and so far I have been unable to successfully get this working
using Xerces-J 1.4.4. Whenever I try to validate a schema[0] with Xerces-J
using sample code obtained from www.xml-schema.com [1], I get the following
wonderful set of errors

Error:  org.xml.sax.SAXParseException: General Schema Error: Grammar with uri
2:
 http://www.w3.org/2001/XMLSchema , can not found.
Error:  org.xml.sax.SAXParseException: Element type "schema" must be declared.
Error:  org.xml.sax.SAXParseException: Element type "annotation" must be
declare
d.
Error:  org.xml.sax.SAXParseException: Element type "documentation" must be
decl
ared.
Error:  org.xml.sax.SAXParseException: Element type "element" must be
declared.
Error:  org.xml.sax.SAXParseException: Element type "element" must be
declared.
Error:  org.xml.sax.SAXParseException: Element type "complexType" must be
declared
*** rest of error message snipped ***

Actually I lied, I commented out the following line of code


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

because it threw a SAXNotRecognizedException. I also get similar errors if I
use the sax.SAXCount class from the xercesSamples.jar file with validation
turned on.

[0] Including po.xsd from the the XML Schema Primer
[1] http://www.xml-schema.com/examples/schema/SchemaValidate.java

--
THINGS TO DO IF I BECOME AN EVIL OVERLORD #26
No matter how well it would perform, I will never construct any sort of
machinery which is completely indestructible except for one small and
virtually inaccessible vulnerable spot.


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

Received on Monday, 7 January 2002 12:50:04 UTC