I am trying to find a library that allows me to place the content of an XML into a JavaBean (something like Digester, Jaxb, JIXB etc) but I need it to be runtime (not at compile time, or by byte code generation) and use a mapping file of some sort.
The idea will be something like Hibernate's HBM mapping files, a way to specify which XML element goes into which Java property. I am currently using Digester but I want something simpler for its rules file.
This should also work on a 1.4 JDK so annotations won't really do (but I will consider such responses just for completeness's sake).
To resume, I need a runtime tool that does XML to Java based on a XML descriptor of some sort, something like this (taken from JIXB) but at runtime (i.e. pass it the XML, the Java class to output object and the mapping descriptor):
Do you know of such a library?
Thank you!
解决方案
Try Castor. It is able to generate java code from DTD (and probably from XSD too). So, you can generate the code at runtime and then compile it.
BTW check JAXB again. I believe that it can do the same.