castor marshall question

Discussions

XML & Web services: castor marshall question

  1. castor marshall question (1 messages)

    Hi,

    I use castor to marshall a java object. There are three objects Service, Group and Unit. The Service object includes a collection of Group. The Group object includes a collection of Unit. Obviously, there are two layers here. When I try to marshall service object, Castor successfully marshall the collection of Group object but can't do correctly for the collection of Unit in the Group object.

    The result is below:
    <service>
      <name>firstONe</name>
      <group>
      <name>2nd group</name>
      <all-unit xsi:type="java:java.util.AbstractList$Itr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
      </group>
    </service>

    mapping file looks like below:
    <mapping>
      <class name="Service">
        <map-to xml="service"/>
        <field name="name">
          <bind-xml name="name" node="element"/>
        </field>
        <field name="groups" collection="collection" type="Group">
          <bind-xml name="group"/>
        </field>
      </class>
      <class name="Group" auto-complete="true">
        <field name="groupName">
          <bind-xml name="name" node="element"/>
        </field>
        <field name="units" collection="collection" type="Unit">
          <bind-xml name="unit"/>
        </field>
      </class>
      <class name="Unit" auto-complete="true">
        <field name="unitName">
          <bind-xml name="name" node="element"/>
        </field>
        <field name="groupName">
          <bind-xml name="groupName" node="element"/>
        </field>
      </class>
    </mapping>

    I'm just wondering if castor doesn't support recursive marshall of collection field.

    Does anyone know that? Thanks in advance.

    Jim
  2. sorry,a mistake from me[ Go to top ]

    please ignore it