Reputation: 23587
Have a requirement so want to check its feasibility.We are using JAXB 2.x for unmarshling XML in to out existing POJO classes.below is the process we are following..
Now there is one requirement so the client want that they can pass XML and XSD to the method being developed and this method should hand over the common object as return by parsing that XML and later on they will handle the process of mapping that generic Object with the specific classes.
My question is,Is it possible in Jaxb 2.x that based on the XSD supplied it will first create required classes on the fly and than will parse XML and hand over the result to the client module so they can do the mapping work or is there any way to achieve that functionality??
Thanks in advance
Upvotes: 1
Views: 5403
Reputation: 148977
In EclipseLink MOXy (I'm the tech lead) we have a feature called Dynamic JAXB, that lets you bootstrap from an XML schema and use generic objects. You might find this approach useful:
Upvotes: 1
Reputation: 1
Have a look at the sample samples/inline-customize located at http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/docs/2.0/jaxb/samples.html
Upvotes: 0
Reputation: 1
I know it Is doable. One student in my lab did almost the same thing on a different subject. Though, you will have to play with classloader to be able to load dynamically the classes you've jest created. Once that is done, you can parse the XML using the classloader that includes the new classes.
Of course, it is not as easy as it sounds like...
Upvotes: 0