开发者

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

开发者 https://www.devze.com 2022-12-19 01:56 出处:网络
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.

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


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.


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?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号