On 7 Feb 2004, at 11:09, Cheong Chung Onn wrote:

Hi all,

I sieved through the archive and found that a year ago, someone has asked a similar question. But the solution seems complicated, and now 1 year has past, i wonder if there is a more elegant way of solving the problem.

i agree that the solution to maps is a little complicated and inelegant and it would be great if better ways could be found. any new ideas would be welcomed :)


Essentially, i have a Map object converted to xml in the form
...
<entry>
        <key> xxx</key>
        <value>yyy</value>
</entry>
...

The problem here is the "Type" info is missing for both <key> and <value>, is it possible now to provide a hint to Betwixt to enable it to do a round trip for a Map object. I am thinking that if i do have a table which maps the <key>s to <value>s Type and assuming all the <key> elements are String typed, can round tripping of a Map instance be done in a simple and straight forward manner?

<entry>
        <key>aPerson</key>          <= aPerson - String type
        <value>                                 <= Person.class
                <person>
                        <name>John Doe</name>
                </person>
        </value>
</entry>

Any suggestion will be much appreciated. Thanks in advance.

here's the way i see this problem...


it's probably quite common that the key for a map will turn out to be a simple value indexing a complex type.

index: "AA11235"
complex type: <person><name>John Doe</name>...</person>

it seems to me that often a natural way to express this in xml would be as an additional attribute so the resultant would be something like:

<person key='AA11235'><name>John Doe</name>...</person>

(the key attribute may or may not exist on the actual object mapped).

does this seem to ring true or are there other, more useful and common strategies for mapping map entries that other people can think up?

- robert


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to