views:

34

answers:

2

The .NET Framework exposes a rather useful set of classes as part of the System.Xml.Schema namespace.

Among other things, classes such as XmlSchema and XmlSchemaElement provide a useful API for defining/writing and parsing/reading/traversing XML schema files.

Does an equivalent library exist for Java?

A: 

Did you take a look at Java.xml.validation?

http://www.ibm.com/developerworks/xml/library/x-javaxmlvalidapi.html

Longball27
I did. I understand it can be used to read a schema resource and use it to validate XML. However, what I really want to be able to do is inspect the schema itself, i.e. traverse it, inspect it's complex types, add new elements etc.
tomtheguvnor
A: 

The tools to accomplish this are there, but I don't think there's anything specific like that in Java. What I would do is run JAXB on the XML Schema schema (http://www.w3.org/2001/XMLSchema), which will generate Java classes corresponding to the XSD constructs. Then you can use those to read/write XML schemas, and validate against the XML Schema schema.

Gabriel