I have an XML Schema. I have written a thin layer over Stax to allow producing conforming documents 'on the fly' (I don't want a dom-like API, I need low/no footprint). The API has just methods like:
writeCar(String manufacturer)
writeWheels(String manufacturer, boolean winter)
...
These perform state checking and then call appropriate stax methods.
A specialty is that there are no writeEndXXX methods (My schema is unambigous, so you can't have any car inside a wheels element. This means I always know when to close open elements). The only exception is that there's a flush() which will write all pending end tags.
writeCar(..) // <car>
writeWheels(..) // inside the car <wheels>
writeCar(..) // close the pending tags </wheels></car> and new car <car>
flush() // this writes all pending close tags
This works nicely. Now the schema evolves :)
I am now updating the API by hand. Because I'm virtuous, I don't want to do that really :). Is there a tool available that would generate such an API (or similar) given an XML Schema definition?