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
--
John Turner
[email protected]


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

   http://xircles.codehaus.org/manage_email


Reply via email to