Hi Basis,
Barış Gerze wrote:
> Hello,
>
> I have the following format
>
> <linked-hash-map>
[snip]
> </linked-hash-map>
>
>
>
> And I want to convert it to the following format
>
>
> <xmlgrid>
[snip]
> </xmlgrid>
>
> How can I do that ? I am confused with Converters..
XStream is in first place a library that can transform Java objects into XML
and back. i.e. the XML contains everything that is required to restore the
original objects. To perform the task is uses for different types
specialized or more generic converters. A converter is responsible to
marshal the object it claims it can handle their type. If an object contains
other objects th converter is free to pass an embedded object back into the
XStream core (implicitly starting a recursion) or manage the XML by itself.
The XML you see in first place is what XStreams MapConverter is generating.
However, you may register an own (custom) converter for (LinkedHash)Maps
that processes the elements in your map the way you need it. If your task is
one way (i.e. you're only generating XML, but you'll never read the XML to
restore the objects), you have even more freedom about the generated format,
because it does not have to contain any information. You do not even have to
implement the unmarshal method of the converter.
Writing converters is an easy task, have a look at the converter tutorial.
It contains anything you'll need to write the requested XML. Just always
keep in mind, that a converter is only responsible for the stuff between the
current tags (and their attributes), but never for the current tag itself.
Cheers,
Jörg
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email