I would use xlst transformations for this. In fact I already did this to create java classes based on a set of XML files containing a data model, but unfortunately I don't have the code right here, now.
With xslt you can create text files from your XML and it is no problem to create text files that are .java files.
Maybe you can try to google "xslt generate java" to get some examples how to do it.
I ran into the problem to need an XSLT processor with enhanced functionality, because I had to write more than one java-file for one XML-file. I think I used XALAN for this, but there should be more XSLT processors with this feature.
subject: How can we convert an xml file to create java file