dm76
dm76

Reputation: 4240

library for XML mapping to Java Object without having to generate source code from xsd at compiletime?

I have always been using jaxb for parsing XML files into java object. This requires generating the java source code from the xsd schema at compiletime.

Now, what if the application needs to parse xml files at runtime which are unknown at compiletime, i.e. provided by users for example ??

David

Upvotes: 2

Views: 448

Answers (4)

Santhosh Kumar Tekuri
Santhosh Kumar Tekuri

Reputation: 3020

If you don't want the java objects to be read generated by binding frameworks, then try

http://code.google.com/p/jlibs/wiki/SAX2JavaBinding

Upvotes: 0

ChadNC
ChadNC

Reputation: 2503

I don't know why you would want to do what you're asking, but I think what you want to can be done using the Streaming API for XML. I have never used it before but reading about the API it seems that it provides something like what you're asking about.

Upvotes: 1

matt b
matt b

Reputation: 139921

You can take a look at XStream for deserializing XML into objects; however, you'll still have to make sure you know the format/schema of the XML you are parsing.

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1500155

In that case you'd be generating the type at execution time too. That can be done, of course - but are you sure you want to? How would you go about using that type afterwards?

Upvotes: 0

Related Questions