Reputation: 269
I want to create an xml dynamically where the xsd will be provided. Here In the program itself I am able to generate the jaxb object with the name of the xsd that I have given. I want to compile this class on the fly and have to unmarshall the xml (Here the jaxb object is unknown). Can anybody help me in doing this? Is there any better option to do this. Here the xml generated should have some variables statically filled while some should be dynamically filled.
Upvotes: 1
Views: 876
Reputation: 43651
This is possible. You can compile and unmarshal in the runtime, but what will you do with the unmarshalled objects then? I mean, since the classes are generated in the runtime you won't be able to access the data actually, will you?
Ok, but nevertheless. Here's some code I wrote for dynamic schema generation and compilation a few years ago. And here's some testing code for that. It worked but I have no idea if it still does.
I think compiling classes in the runtime is the wrong way. Better check the dynamic approaches from MOXy. I think you might be interested in dynamic bootstraping from an XML Schema.
Upvotes: 2