Hi John,

ignoring that your clas mappings below do not define <map-to /> directives, the field mapping for Cart's itemsList property should be as follows:

<field name="itemsList" collection="arraylist" type="Item">
 <bind-xml name="item" location="foo/items-list" />
</field>

This should do it.

Regards
Werner

On 04.07.2012 07:38, John Turner wrote:
I have a problem similar to that addressed by the 'How to map a
collection of elements'
(http://www.castor.org/how-to-map-a-collection.html).  I need to
un-marshal an XML document that contains a collection.  The tag at the
collection level is inside another nested tag.

My input XML is:

<cart>
   <foo>
     <items-list>
       <item count="1">broccoli</item>
       <item count="4">orange</item>
     </items-list>
   </foo>
</cart>

I have tried this mapping (and others!):

<mapping>
   <class name="Cart" auto-complete="true">
     <field name="itemsList" collection="arraylist" type="Item"
         container="false">
       <bind-xml name="items-list" location="foo" />
     </field>
   </class>
   <class name="Item" >
     <field name="Name" type="java.lang.String">
       <bind-xml name="item" node="text" />
     </field>
     <field name="Count" type="java.lang.Integer">
       <bind-xml name="count" node="attribute" />
     </field>
   </class>
</mapping>

I get this error message:

Unable to find FieldDescriptor for 'foo' in ClassDescriptor of cart.

The Cart and Item classes are as per the how-to referenced above.

Please can somebody suggest a mapping that accommodates the "foo" tag?
(Note: my XML is coming from a legacy system and cannot be altered).

Thanks, John


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

   http://xircles.codehaus.org/manage_email


Reply via email to