I am receiving an XML document from a REST service which shall be parsed using SAX. Please see the following example which was generated out of the XSD.
Setting up th
Generally speaking you have a couple choices:
To my knowledge there are some tools out there such as JAXB which will generate your classes based on XSD's, but they can sometimes come with a price as generated code often does.
If you go with option 1 and "roll your own" you'll need to provide methods for unmarshaling and marshaling that go to and from XML and most likely Strings. Something like:
// pseudo-code!
//In Foo.java
unmarshal( Element element ) {
unmarshalBar( element );
unmarshalThing( element );
}
unmarshalBar( Element element ) {
//...verify that the element is bar
bar = new Bar();
bar.unmarshal( element );
}
//In Bar.java
unmarshal( Element element ) {
unmarshalBaz( element );
}
Hope this helps.