[jdom-interest] xml schema validation using Xerces 2, ValidateJDOM example
Clint Frederickson
clintf at neo.cs.montana.edu
Tue May 14 10:42:12 PDT 2002
I have been trying to get jdom (beta 8, using Xerces 2) to validate an
XML document with a matching schema. I have read the FAQ and a couple of
posts by Kevin Jones in addition to downloading his ValidateJDOM.java
example. I cannot, however, validate the example XML - XSD pair given on
http://www.w3schools.com/schema/schema_example.asp . I have hardcoded
ValidateJDOM to say (eliminating the need for second command line
parameter):
sb.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation",
"http://www.w3.org/2001/XMLSchema
simple.xsd");
My resulting java command looks like:
java com/develop/ejws/schema/ValidateJDOM simple.xml
The first few lines of the resulting stack trace look like:
org.jdom.JDOMException: Error on line 5 of document
file:///home/clintf/programming/XMLTest/validate/src/simple.xml: General
Schema Error: Schema in simple.xsd has a different target namespace from
the one specified in the instance document
:http://www.w3.org/2001/XMLSchema.
(note: I have renamed the xml - xsd file pair given on w3schools webiste
to simple.xml and simple.xsd, and changed the XML files appropriately.
Also, both these files are in the directory I'm running the java command
from)
Perhaps I don't understand how to use the ValidateJDOM class correctly.
Does anyone have a working example of how to use ValidateJDOM on an
example XML - XSD pair? I'm probably missing something very simple here.
Thanks in advance for your help,
--Clint M. Frederickson
More information about the jdom-interest
mailing list