I have used the scomp tool from XMLBeans to generate java classes and then populated the fields in an XmlObject (I wrote this code some time ago). ...
scomp