I worked on a project for which we chose to use JAXB, which can validate an XML document for compliance with an XML schema before creating a Java rendering of it.
Can XStream validate an XML document against a schema?
I couldn’t resist this opportunity to give xstream a spin :)
And as far as XML encoder goes, it performs very nicely indeed.
The resulting XML is very nice and around 5 time smaller than the one produced by JSX (and somewhat smaller than what java.beans.XMLEncoder creates).
As far as speed goes, xstream is somewhat faster than JSX and XMLDecoder for write operations. But it seems to be somewhat slower for reads (?).
Using the default Java serialization mechanism as implemented by ObjectOutputStream/ObjectInputStream as a benchmark, xstream is about 4 time more verbose than Java serialization format. Ditto for speed: Java serialization is about 4 time faster for write and around 20 time faster for read (???). Of course, YMMV.
(I’m not quiet sure why xstream seems to struggle so much with read operations though)
While xstream is very nice as it is, is would be even nicer if it could be used as a drop-in replacement for ObjectStream… :)
Hi.
Does XStream has dependency on J2SDK1.4 and not backword compatible.I was getting ClassDefNotFound sun.reflect.ReflectionFactory with jdk1.3.1 but when run with j2sdk1.4 it works fine.Can u suggest.
Pritam – create your own objectfactory and pass it in.
Joe – I have made a few changes to the code. I Submitted them on jira:
1. It allows circular references by using a unique integer id for each. This is ONLY changed in objectwithfieldsconverter.
2. I changed the null fields to look like:
3. I haven’t done the reading part – you will know more about it.
I do not know how to write this code in a single place when you have so many converters. Maybe you should look at using a pico-type inversion of control mechanism ? Pico is overkill for the problem, but ioc3 isnt if I understand it correctly.
It looks like someone has finally come up with the missing link! Java has needed a tool like this for a long time (liberally open source licensed instead of proprietary).
I can confirm the results which Zoe provided. Compared to JSX, I (in general) find the design of XStream more clean – but I would very much like to see some improvements regarding speed over time. Thanks for a great alternative to JSX and even better it’s open source ;-) Keep up the brilliant work.
I worked on a project for which we chose to use JAXB, which can validate an XML document for compliance with an XML schema before creating a Java rendering of it.
Can XStream validate an XML document against a schema?
I couldn’t resist this opportunity to give xstream a spin :)
And as far as XML encoder goes, it performs very nicely indeed.
The resulting XML is very nice and around 5 time smaller than the one produced by JSX (and somewhat smaller than what java.beans.XMLEncoder creates).
As far as speed goes, xstream is somewhat faster than JSX and XMLDecoder for write operations. But it seems to be somewhat slower for reads (?).
Using the default Java serialization mechanism as implemented by ObjectOutputStream/ObjectInputStream as a benchmark, xstream is about 4 time more verbose than Java serialization format. Ditto for speed: Java serialization is about 4 time faster for write and around 20 time faster for read (???). Of course, YMMV.
(I’m not quiet sure why xstream seems to struggle so much with read operations though)
While xstream is very nice as it is, is would be even nicer if it could be used as a drop-in replacement for ObjectStream… :)
Hi.
Does XStream has dependency on J2SDK1.4 and not backword compatible.I was getting ClassDefNotFound sun.reflect.ReflectionFactory with jdk1.3.1 but when run with j2sdk1.4 it works fine.Can u suggest.
Pritam – create your own objectfactory and pass it in.
Joe – I have made a few changes to the code. I Submitted them on jira:
1. It allows circular references by using a unique integer id for each. This is ONLY changed in objectwithfieldsconverter.
2. I changed the null fields to look like:
3. I haven’t done the reading part – you will know more about it.
I do not know how to write this code in a single place when you have so many converters. Maybe you should look at using a pico-type inversion of control mechanism ? Pico is overkill for the problem, but ioc3 isnt if I understand it correctly.
Great project!
The xml didnt come out on number 2. Check on jira.
This great project. Please complete circular reference!
It looks like someone has finally come up with the missing link! Java has needed a tool like this for a long time (liberally open source licensed instead of proprietary).
Keep up the good work.
Gregor
I can confirm the results which Zoe provided. Compared to JSX, I (in general) find the design of XStream more clean – but I would very much like to see some improvements regarding speed over time. Thanks for a great alternative to JSX and even better it’s open source ;-) Keep up the brilliant work.
/Jens
The [ultimate] test for xstream :
XStream stream = new XStream();
String data = stream.toXML(new JTable());
// will throw outofmemoryexception here!