Hi,

I hope you can help.  I have the following scenario...

<classRoom>
        <childList>
                <pupil key="01">
                        <name>Joe</name>
                </pupil>
                <pupil key="02">
                        <name>Jane</name>
                </pupil>
                <pupil key="03">
                        <name>Jack</name>
                </pupil>
        </childList>
</classRoom>

And I want to be able to map this to the following classes

public class ClassRoom {

        public Map children = new HashMap();
        
        public ClassRoom() {
        }
}

public class Child {

        public String id = null;
        public String name = null;
        
        public Child() {
        }
}

I have tried to map the classes in the following way...

<mapping>
        <class name="castor.ClassRoom">
                <map-to xml="classRoom"/>

             <field name="children" collection="map" direct="true">
                 <bind-xml location="childList">
                     <class name="org.exolab.castor.mapping.MapItem">
                         <field name="key" type="java.lang.String">
                             <bind-xml name="key" location="pupil" 
node="attribute"/>
                         </field>
                         <field name="value" type="castor.Child">
                             <bind-xml name="pupil" node="element"/>
                         </field>         
                     </class>
                 </bind-xml>
             </field>
        </class>

        <class name="castor.Child">
                <field name="id" type="string" direct="true">
                        <bind-xml name="key" node="attribute"/>
                </field>
        
                <field name="name" type="string" direct="true">
                        <bind-xml name="name" node="element"/>
                </field>
        </class>
</mapping>

Can you please advise as to what I am doing wrong or if another approach is 
available, unfortunately I can not change the original XML data file.

Thanks

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

    http://xircles.codehaus.org/manage_email


Reply via email to