We have a class that wraps a HashMap. When marshalled we want the bind-to names of the fields to be the same as the keys of the HashMap. The values will be the textual data in the generated elements.
The values are currently coming through, but we don't know how to reference the keys in the name attribute of the bind-to element. Here is the mapping.xml file: <?xml version="1.0" ?> <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version 1.0//EN" "http://castor.exolab.org/mapping.dtd"> <mapping> <class name="mypackage.CastorWrapper"> <map-to xml="data" /> <field name="candy" type="java.lang.String" collection="map"> <bind-xml name="variable" node="element" /> </field> </class> </mapping> Here is the class to be marshalled: package mypackage; import java.util.*; public class CastorWrapper { public Map getCandy() { return candy; } public void setCandy(Map m) { candy = m; } public static void main(String[] args) { CastorWrapper cw = new CastorWrapper(); System.out.println(cw.getClass().getName()); } private static final String CLASS_NAME = "CastorWrapper"; private Map candy = new HashMap(); } The HashMap includes form data, such as; Head="Bla bla bla" SubHead="dron drone drone" Image="image.jpg" The current outputted XML is: <data><variable>5654ytr456756</variable><variable>sdfhtykiyu</variable><variable>20052600.jpg</variable></data> Desired output: <data><Head>5654ytr456756</Head><SubHead>sdfhtykiyu</SubHead><Image>20052600.jpg</Image></data> Is this possible from a mapping.xml file or do we need to look into creating our own FieldHandler class? Thanks for your time. ===== Martyn Wilson __________________________________________________ Do you Yahoo!? U2 on LAUNCH - Exclusive greatest hits videos http://launch.yahoo.com/u2 ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
