Java Mailing List Archive

Home » user.castor »

[castor-user] How to map a collection within a nested tag?

John Turner


Replies: Find Java Web Hosting

Author LoginPost Reply
I have a problem similar to that addressed by the 'How to map a
collection of elements'
( 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:

    <item count="1">broccoli</item>
    <item count="4">orange</item>

I have tried this mapping (and others!):

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

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

To unsubscribe from this list, please visit:

©2008 - Jax Systems, LLC, U.S.A.