[Simple-support] @ElementMap can't deserialize repetitive custom typed inline elements
Brought to you by:
niallg
|
From: Stumpf, J. T. <Tho...@st...> - 2011-06-18 09:13:50
|
Hi!
I tried a lot of different annotations following the tutorials but none of it was able to deserialize the following given structure (correctly):
<document>
...
<media>
<image id="media-1" src="img.png" name="Arthur Spooner" title="img one">my car</image>
<image id="media-2" src="img2.png" name="Arthur Spooner" title="img two">a better image of my car</image>
<image id="media-3" src="img3.png" name="Poison Ivy" title="img three">awesome flower</image>
<video id="video-1" src="mov1.mpg" name="Rohrschach" title="cool movie">man running in circles</video>
</media>
...
Image and Video class simply implement all attributes and Elements.
I tried, similar as shown in the tutorials, within class document
@ElementMap(inline=true,entry="image",key="id",attribute=true)
@Path("media")
Map<String, Image> images;
@ElementMap(inline=true,entry="video",key="id",attribute=true)
@Path("media")
Map<String, Video> videos;
Because this seemed to be problematic because of the mixed content I created an own class Media.
(Question: How could this issue be solved with @Union? The combination of Union and ElementMap annotation seems not to work)
Within Media class I tried
@ElementMap(inline=true,entry="image",key="id",attribute=true)
Map<String, Image> images;
...not further going to mention video, it's basically the same...
And I tried
@ElementMap(inline=true,key="id",attribute=true)
Map<String, Image> images;
and
@ElementMap(inline=true,value="image",key="id",attribute=true)
Map<String, Image> images;
as well as
@ElementMap(entry="image",key="id",attribute=true)
Map<String, Image> images;
and so on.
None of them worked as intended.
How can I generate a map of images, videos, you-name-it elements with the attribute id as key?
In fact I would like to get a sortable/navigable Map, e.g. TreeMap, and it would be good not to be forced to implement a Media class.
Can anybody help?
I most probably miss something.
For the time being I implemented it as Dictionary - the drawback is the name clash of the attributes and the methods.
I appreciate any input!
Thx in advance
Jens
|