5

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?

zedoo
  • 10,562
  • 12
  • 44
  • 55

1 Answers1

0

JAXB Based

  1. Generate an XSD from your XML. You can use also this link or another tool works fine.
  2. Generate classes from XSD by XJC, Maven plugin see here
  3. Using any JAXB tutorial to perform marshal and unmarshal to read and write xml. see here

I suggest you also these link

I hope it can help you

Community
  • 1
  • 1
Xstian
  • 8,184
  • 10
  • 42
  • 72