RE: Validating Schemas With Xerces

It would be easier to tell what the problem was if .xml file was
included....

I just went to http://www.xml-schema.com/examples/ ... made a new directory:
c:\temp\144 and into that directory I downloaded  SchemaValidate.java
(http://www.xml-schema.com/examples/schema/SchemaValidate.java), 
editor.xml (http://www.xml-schema.com/examples/schema/editor.xml),
buildSchemaValidate144.bat
(http://www.xml-schema.com/examples/schema/buildSchemaValidate144.bat),
runSchemaValidate144.bat
(http://www.xml-schema.com/examples/schema/runSchemaValidate144.bat)

I made sure that buildSchemaValidate144.bat was pointing to my 144 version
of xerces.jar.
I ran buildSchemaValidate144.bat and which gave me
c:\temp\144\SchemaValidate.class
I made sure that runSchemaValidate144.bat pointed to my 144 version of
xerces.jar and was going to process editor.xml.
I ran runSchemaValidate144.bat and there was almost no output (meaning all
validated).

If you download editorbad.xml you can see output when problem with instance
document.

I had some problems with this stuff when I was using a system classpath
because I was having 144 vs 200 compat problems (build with 144 didn't like
to run with 200 if I recall properly).  Use of batch files makes classpath
explicit.

Tom


-----Original Message-----
From: Dare Obasanjo [mailto:kpako@yahoo.com]
Sent: Monday, January 07, 2002 3:49 PM
To: xmlschema-dev@w3.org
Subject: 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-che
ck
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 13:26:35 UTC