Hi,
I don't think we have support for this feature, to be honest. And I am
not sure whether this could be added.
Let me rephrase this: it could be added, but it might need somé good
refactoring. Would you be willing to help ?
Werner
codemaniac wrote:
> 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
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email