I would like to iterate through a map object populated dynamically and use
castor to generate xml which has the element/attribute name as the item key 
and value as item value. I don't want the nodes create from items in the to
be a child of another node.

Example:
map1.put("firstName","John")
map1.put("lastName","Doe")


Castor Should populate the elements in the xml like the following:

<firstName> John </firstName> 
<lastName> Doe </nameName> 

I would like to also generate dynamic attributes for an element. 

Can anyone provide me with an example or solution please ? I have tried
using the follwing in the mapping file, but it does not work. I get key and
value as node names.


<field name="children" 
type="org.exolab.castor.mapping.MapItem" collection="map" 
get-method="getChildren" 
<bind-xml> 
<map-key name="item.key" node="element"/> 
<map-value name="item.value"node="element"/> 
</bind-xml> 


Creates:

<key xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:type="java:java.lang.String">name</key><value
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:type="java:java.lang.String">John</value></map-item><map-item><key
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:type="java:java.lang.String">lastName</key><value
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:type="java:java.lang.String">Doe</value></map-item>

- Thanks asajnani
-- 
View this message in context: 
http://www.nabble.com/Help-needed-in-setting-Dynamic-Field-names-values-for-elements-attributes-tp17364128p17364128.html
Sent from the Castor - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to