I removed "xsi:" in the file and came up with the following mapping:

<?xml version="1.0"?>


<mapping>

<class name="com.Root">
<map-to xml="Root"/>

<field name="v_Sub" type="com.Sub">
<bind-xml name="Sub" node="element"/>
</field>

</class>


<class name="com.Sub">
<map-to xml="Sub"/>

<field name="v_C" type="com.C">
<bind-xml name="C" node="element"/>
</field>

</class>


<class name="com.C">
<map-to xml="C"/>

<field name="C1_list" type="com.C1" collection="arraylist">
<bind-xml name="C1"/>
</field>

</class>


<class name="com.C1">
<map-to xml="C1"/>

<field name="TEST1" type="string">
<bind-xml name="test1" node="element"/>
</field>
<field name="v_test2" type="com.test2">
<bind-xml name="test2" node="element"/>
</field>
<field name="TEST3" type="string">
<bind-xml name="test3" node="element"/>
</field>
<field name="v_test4" type="com.test4">
<bind-xml name="test4" node="element"/>
</field>

</class>


</mapping>

-Henry


On 7/29/2010 10:27 AM, sric1 wrote:
Hello,

I am really struggling with castor. I am using castor 1.3.1. I have used
castor generated classes for mapping but i faced issues with class loader.
Now i am going to XML based mapping instead of generated classes. But could
not find enough information on mapping nested elements. Could anyone help me
with this.

Sample xml message:
<Root>
    <Sub>
        <C>
          <C1>
              <test1>ac6556979b44</test1>
              <test2 xsi:nil="true"/>
              <test3>message</test3>
              <test4 xsi:nil="true"/>
          </C1>
          <C1>
              <test1>b3quiqioe8ii</test1>
              <test2 xsi:nil="true"/>
              <test3>message2</test3>
              <test4 xsi:nil="true"/>
          </C1>
           <C1>
              <test1>naciehi6373</test1>
              <test2 xsi:nil="true"/>
              <test3>message3</test3>
              <test4 xsi:nil="true"/>
           </C1>
        </C>
      </Sub>
    </Root>


Here element "C" contains multiple(array of) C1 elements.

Mapping file:
<code>
<mapping xmlns="http://castor.exolab.org/";>
        <class name="org.test.Root">
                <map-to xml="Root" />
                <field name="Sub" type="org.test.Sub"
                        required="true">
                        <bind-xml name="Sub" node="element"/>
                </field>
        </class>

        <class name="org.test.Sub">
                <field name="Sub"
                        type="org.test.Sub" required="true">
                        <bind-xml name="C" node="element" />
                </field>
        </class>
        <class name="org.test.C">
                <field name="C"
                        type="org.test.C" required="false" 
collection="arraylist">
                        <bind-xml name="C1" node="element" />
                </field>
        </class>
        <class name="org.test.C1">
                <field name="test1" type="java.lang.String">
                        <bind-xml name="test1" node="element" />
                </field>
                <field name="test2" type="java.lang.String">
                        <bind-xml name="test2" node="element" />
                </field>
                <field name="test3" type="java.lang.String">
                        <bind-xml name="test3" node="element" />
                </field>
                <field name="test4" type="java.lang.String">
                        <bind-xml name="test4" node="element" />
                </field>
        </class>
</mapping>
</code>

I am getting all kinds of unmarshalling exceptions. Any help would be
greatly appreciated.


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

   http://xircles.codehaus.org/manage_email


Reply via email to