On Tue, 25 Jan 2005 12:32:50 -0500, Mauricio Alarcon
<[EMAIL PROTECTED]> wrote:

> This might be a silly question, but I haven't been able to do this (also
> I'm newbie to Castor), but I need some clues
> 
> I've got a Hashmap in the following way
> 
> key: LocId   value:251
> key: ExpYrsCt value: 5
> .....
> (several key/value pairs)
> 
> and I want to convert that into something like
> 
> <key>value</key>
> 
> So the result will be
> 
> <LocId>251</LocId>
> <ExpYrsCt >5</ExpYrsCt>
> ..
> 
> How can I do this behavior?

Mauricio, 

AFAIK, there is no manner in which to coax Castor into using the keys
as elements in the marshalled XML.

Below is some info regarding the mapping of Hashtable, HashMap and Map
fields taken from the following page:

http://www.castor.org/xml-mapping.html

'For hashtable and maps (since 0.9.5.3), Castor will save both key and
values. When marshalling output <key> and <value> elements. These
names can be controlled by using a top-level or nested class mapping
for the org.exolab.castor.mapping.MapItem class.

Note: for backward compatibility with prior versions of Castor, the
saveMapKeys property can be set to false in the castor.properties
file.

For versions prior to 0.9.5.3, hashtable and maps, Castor will save
only the value during marshalling and during unmarshalling will add a
map entry using the object as both the key and value, e.g.
map.put(object, object). '

See also the Nested Class Mapping info on the same page but a
different section:

http://www.castor.org/xml-mapping.html#3.5-The-%3Cbind-xml%3E-element

HTH. 

Bruce 
-- 
perl -e 'print unpack("u30","<0G)[EMAIL 
PROTECTED]&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'

The Castor Project
http://www.castor.org/

Apache Geronimo
http://geronimo.apache.org/



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to