views:

38

answers:

2

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?

+1  A: 

Super-short answer: http://download.oracle.com/javase/1.5.0/docs/api/javax/xml/validation/package-summary.html

Malax
I would like to validate an XSD Schema, not a normal XML File!
simonh
Schemas *are* normal XML files. They have a schema for schemas [http://www.w3.org/2001/XMLSchema.xsd], so you can check your Schema XML file to see if it is schema valid.
Mads Hansen
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.
jasso
A: 

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.

bmargulies