I'm making use of an API on the internet that is marshalling objects to XML files. Given that the XSD files are also available I'd like to be able to unmarshall them back in to Java objects once I've downloaded the files.
After looking around it looks like JAXB is the default library for doing this in Java, but as I'm developing a mobile app the extra 8.6MB dependency just isn't acceptable. I also found XStream, but it still weighs in at 7.9MB.
Poking around the Android SDK it looks like the only real XML parser available is SAX.
So here's the question:
Thanks.
The Unmarshaller class governs the process of deserializing XML data into newly created Java content trees, optionally validating the XML data as it is unmarshalled. It provides an overloading of unmarshal methods for many different input kinds.
XML provides a universal syntax for Java semantics (behavior). Simply put, this means that a developer can create descriptions for different types of data to make the data behave in various ways with Java programming code, and can later repeatedly use and modify those descriptions.
Android uses xml to declare layouts and java to provide logic. Note that while both activity_main and MainActivity follow common naming conventions, there is no need for them to be called this way.
There is a framework that will work on Android which does Java to XML binding using annotations in a similar manner to JAXB, it is called Simple and weighs in at less than 270K, thats a tiny fraction of whats required for XStream or JAXB. Also, it has no external dependencies, just one JAR and everything should work. Below is a link to Simple, and XML serialization framework for Java.
http://simple.sourceforge.net
This can also handle cycles in object graphs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With