Hi,
You define LinkedHashMap as java.util.map and
LinkedList as collection in your mapping file. Then it will get marshalled.
While unmarshalling it will return map and
collection, typecast into LinkedHashMap and LinkedList respectively.
Regards
From: Xinjun Chen
[mailto:[EMAIL PROTECTED]
Sent: Thursday, December 29, 2005
11:04 AM
To: [email protected]
Subject: Re: [castor-user]
Defining a Hashtable in the XML mapping
I have the same problem of marshalling and unmarshalling Hashtable,
have you successfully done it?
On 12/23/05, Ralf
Joachim <[EMAIL PROTECTED]>
wrote:
Hi Roland,
I'm not one of the Castor XML experts but as far as I know this should
be possible. I would suggest you to start with marshalling a sample
object first without mapping and then by using a mapping that you modify
step by step until your xml document looks like you want it to. I would
expect the unmarshalling of this document to work also with the same
mapping then.
Having said that I guess your mapping should not be to far away of what
it should be.
Regards
Ralf
Castor JDO, committer
[EMAIL PROTECTED] schrieb:
> Hi all,
>
> I want to use Castor XML to fill a Hashtable in my class from an XML file.
> This Hashtable should map Strings to Hashsets which contain also Strings.
> Unfortunately, I could not find an example for this.
>
> Here is what I currently have in the mapping file:
>
> <field name="myHashtable"
collection="hashtable">
> <bind-xml
name="myHashtable" node="element">
> <class
name="org.exolab.castor.mapping.MapItem">
>
<field name="key" type="java.lang.String">
>
<bind-xml name="key" node="element"/>
>
</field>
>
<field name="value" type="java.util.HashSet">
>
<bind-xml name="value" node="element"/>
>
</field>
> </class>
> </bind-xml>
> </field>
>
>
> And this is in the source XML:
>
> <myHashtable xsi:type="java: java.lang.String"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <key
key="mykey" xsi:type="java:java.util.Hashset "
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>
<value xsi:type="java:java.lang.String"
> xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance">myvalue</value>
> </key>
> </myHashtable>
>
>
> Any ideas how this code should look like? Is this even possible with
Castor
> XML?
>
> Thanks in advance for your help.
>
>
> Greetings,
> Roland
>
> -------------------------------------------------
> If you wish to unsubscribe from this list, please
> send an empty message to the following address:
>
> [EMAIL PROTECTED]
> -------------------------------------------------
--
Syscon Ingenieurbüro für
Meß- und Datentechnik GmbH
Ralf Joachim
Raiffeisenstraße 11
D-72127 Kusterdingen
Germany
Tel. +49 7071 3690 52
Mobil: +49 173 9630135
Fax +49 7071 3690 98
Email: [EMAIL PROTECTED]
Web: www.syscon-world.de
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------
|