I would like to automatically validate that an XSD Schema is correct. Is there a java API or something Í can call to do this automatically?
2 Answers
Super-short answer: http://download.oracle.com/javase/1.5.0/docs/api/javax/xml/validation/package-summary.html
3 Comments
Dr. Simon Harrer
I would like to validate an XSD Schema, not a normal XML File!
Mads Hansen
Schemas are normal XML files. They have a schema for schemas [w3.org/2001/XMLSchema.xsd], so you can check your Schema XML file to see if it is schema valid.
jasso
Schema can be malformed even if it is valid according to schema for schemas. because of restrictions in XML schema language all the validity constraints of schema document cannot be expressed in the schema for schemas. AFAIK the SchemaFactory class should report an error even in when you try to create a new Schema-object based on a malformed schema-document even if that document would validate against schema for schemas.
This can be done with Xerces. We did in in Apache CXF. The easiest thing is to read the source.
To look at just the subproject that does this, read here.