Yeah, I am sure there will be something in Xstream to complain about :-) I
am working on an XML-heavy project right now and all existing tools that I
tried to date (I haven't checked Xstream) were a huge disapponitment.
My major complaint was that all object-to-xml-and-back converters do not
allow *mapping*. So if you have a certain XML format you can only convert
it to some default type of objects. If your object tree strcutre is a bit
different, you are out of luck..
For encoding I ended up using Velocity templates (yikes!), so I can treat
the output XML as unstructured data and only bind dynamic pieces. For
decoding I had to write manual parsers using DOM and XPath ... Not hapy
with either approach...
Andrus
> Andrus,
>
> I just ran a couple of tests using the Xstream stuff, using some test
> examples I have been using with our XMLcoder and Decoder.
>
> Here is the code that I added to the cayenne-web-app example:
>
> XStream xstream = new XStream(new DomDriver()); // does not
> require
> XPP3 library
>
> xstream.alias("artist", Artist.class);
>
> String xml = xstream.toXML(artists);
>
> System.out.println(xml);
>
> And here is the resulting generated XML:
> <list>
> <artist serialization="custom">
> <org.objectstyle.cayenne.CayenneDataObject>
> <int>3</int>
> <org.objectstyle.cayenne.ObjectId>
> <objectIdKeys class="java.util.Collections-SingletonMap">
> <k class="string">ARTIST_ID</k>
> <v class="int">1</v>
> </objectIdKeys>
> <objectClass>webtest.Artist</objectClass>
> <hashCode>-26571346</hashCode>
> </org.objectstyle.cayenne.ObjectId>
> </org.objectstyle.cayenne.CayenneDataObject>
> </artist>
> <artist serialization="custom">
> <org.objectstyle.cayenne.CayenneDataObject>
> <int>3</int>
> <org.objectstyle.cayenne.ObjectId>
> <objectIdKeys class="java.util.Collections-SingletonMap">
> <k class="string">ARTIST_ID</k>
> <v class="int">3</v>
> </objectIdKeys>
> <objectClass>webtest.Artist</objectClass>
> <hashCode>-26571344</hashCode>
> </org.objectstyle.cayenne.ObjectId>
> </org.objectstyle.cayenne.CayenneDataObject>
> </artist>
> <artist serialization="custom">
> <org.objectstyle.cayenne.CayenneDataObject>
> <int>3</int>
> <org.objectstyle.cayenne.ObjectId>
> <objectIdKeys class="java.util.Collections-SingletonMap">
> <k class="string">ARTIST_ID</k>
> <v class="int">4</v>
> </objectIdKeys>
> <objectClass>webtest.Artist</objectClass>
> <hashCode>-26571343</hashCode>
> </org.objectstyle.cayenne.ObjectId>
> </org.objectstyle.cayenne.CayenneDataObject>
> </artist>
> <artist serialization="custom">
> <org.objectstyle.cayenne.CayenneDataObject>
> <int>3</int>
> <org.objectstyle.cayenne.ObjectId>
> <objectIdKeys class="java.util.Collections-SingletonMap">
> <k class="string">ARTIST_ID</k>
> <v class="int">2</v>
> </objectIdKeys>
> <objectClass>webtest.Artist</objectClass>
> <hashCode>-26571345</hashCode>
> </org.objectstyle.cayenne.ObjectId>
> </org.objectstyle.cayenne.CayenneDataObject>
> </artist>
> </list>
>
> One of the advantages of our method is that you can use a mapping file
> so you have complete control over the resulting XML and potentially it
> is a lot cleaner. I think that other thing is that you lose the name of
> the relationship and it will harder to parse.
>
> I will look into the Xstream stuff further.
>
> -John
>
>
>
> On 5/12/05 10:29 AM, "Andrus Adamchik" <andru..bjectstyle.org> wrote:
>
>>> Andrus just mentioned the XML serialization feature..how far along is
>>> this? I ask because I recently used XStream
>>> (http://xtstream.codehaus.org/) and found it fantastically easy to
>>> use and also very fast. Just an idea..
>>>
>>> Holger
>>
>> This was developed by Kevin Menard and AFAIK this is still pretty
>> unstable (http://objectstyle.org/confluence/display/CAY/2005/03/09/).
>>
>> I need to check out xtstream. If it happens to be something usable and
>> easy to integrate with Cayenne, my vote would be to kill our own
>> implementation.
>>
>> Andrus
>>
>>
>>
This archive was generated by hypermail 2.0.0 : Thu May 12 2005 - 14:05:13 EDT