|
Hi all,
Question:
I've two collections of array type in my XML message, with
different "location" (see objReserv and cntsReserv)
Each collection element have the name "item" in both
collections.
All the Items are set in the same class when
unmarshalling.
How to dispatch the right item in the right class during
unmarshalling process ?
Thanks.
Samples:
**********************************************************
The mapping file
********************************************************** <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version 1.0//EN" "http://castor.exolab.org/mapping.dtd"> <mapping> <class name="lu.etat.culture.patsi.reserv.Reservation" auto-complete="false"> <description>Default mapping for class lu.etat.culture.patsi.reserv.Reservation</description> <map-to xml="reservation"/> <field name="travId" type="long" required="false" direct="false" transient="false"> <bind-xml name="travId" node="attribute"/> </field> <field name="resEmbargo" type="integer" required="false" direct="false" transient="false"> <bind-xml name="resEmbargo" node="attribute"/> </field> <field name="resId" type="long" required="false" direct="false" transient="false"> <bind-xml name="resId" node="attribute"/> </field> <field name="resDateFin" type="date" required="false" direct="false" transient="false"> <bind-xml name="resDateFin" node="element"/> </field> <field name="resComment" type="string" required="false" direct="false" transient="false"> <bind-xml name="resComment" node="element"/> </field> <field name="objReser" type="lu.etat.culture.patsi.reserv.ObjReser" required="false" direct="false" transient="false" collection="array"> <bind-xml name="objReser" node="element" matches="87" location="objets"/> </field> <field name="resRaison" type="string" required="false" direct="false" transient="false"> <bind-xml name="resRaison" node="element"/> </field> <field name="travail" type="lu.etat.culture.patsi.reserv.Travaux" required="false" direct="false" transient="false"> <bind-xml name="travail" node="element"/> </field> <field name="cntsReser" type="lu.etat.culture.patsi.reserv.CntsReser" required="false" direct="false" transient="false" collection="array"> <bind-xml name="cntsReser" node="element" matches="f" location="contacts"/> </field> <field name="resType" type="string" required="false" direct="false" transient="false"> <bind-xml name="resType" node="element"/> </field> <field name="resDateDebut" type="date" required="false" direct="false" transient="false"> <bind-xml name="resDateDebut" node="element"/> </field> <field name="collReser" type="lu.etat.culture.patsi.reserv.CollReser" required="false" direct="false" transient="false" collection="array"> <bind-xml name="collReser" node="element"/> </field> </class> <class name="lu.etat.culture.patsi.reserv.CntsReser" auto-complete="false"> <description>Default mapping for class lu.etat.culture.patsi.reserv.CntsReser</description> <map-to xml="cntsReser"/> <field name="cntsId" type="long" required="false" direct="false" transient="false"> <bind-xml name="cntsId" node="attribute"/> </field> <field name="cntsEntite" type="string" required="false" direct="false" transient="false"> <bind-xml name="cntsEntite" node="element"/> </field> <field name="relatRole" type="string" required="false" direct="false" transient="false"> <bind-xml name="relatRole" node="element"/> </field> <field name="cntsCivilite" type="string" required="false" direct="false" transient="false"> <bind-xml name="cntsCivilite" node="element"/> </field> <field name="relatComment" type="string" required="false" direct="false" transient="false"> <bind-xml name="relatComment" node="element"/> </field> <field name="relatDateValfin" type="date" required="false" direct="false" transient="false"> <bind-xml name="relatDateValfin" node="element"/> </field> <field name="cntsAdr1" type="string" required="false" direct="false" transient="false"> <bind-xml name="cntsAdr1" node="element"/> </field> <field name="cntsPays" type="string" required="false" direct="false" transient="false"> <bind-xml name="cntsPays" node="element"/> </field> <field name="cntsPrenom" type="string" required="false" direct="false" transient="false"> <bind-xml name="cntsPrenom" node="element"/> </field> <field name="relatDateValdeb" type="date" required="false" direct="false" transient="false"> <bind-xml name="relatDateValdeb" node="element"/> </field> <field name="cntsVille" type="string" required="false" direct="false" transient="false"> <bind-xml name="cntsVille" node="element"/> </field> <field name="cntsEtat" type="string" required="false" direct="false" transient="false"> <bind-xml name="cntsEtat" node="element"/> </field> <field name="cntsNom" type="string" required="false" direct="false" transient="false"> <bind-xml name="cntsNom" node="element"/> </field> </class> <class name="lu.etat.culture.patsi.reserv.ObjReser" auto-complete="false"> <description>Default mapping for class lu.etat.culture.patsi.reserv.ObjReser</description> <map-to xml="objReser"/> <field name="objId" type="long" required="false" direct="false" transient="false"> <bind-xml name="objId" node="attribute"/> </field> <field name="relatValLocation" type="double" required="false" direct="false" transient="false"> <bind-xml name="relatValLocation" node="attribute"/> </field> <field name="relatRetour" type="integer" required="false" direct="false" transient="false"> <bind-xml name="relatRetour" node="attribute"/> </field> <field name="categorie" type="string" required="false" direct="false" transient="false"> <bind-xml name="categorie" node="element"/> </field> <field name="relatComment" type="string" required="false" direct="false" transient="false"> <bind-xml name="relatComment" node="element"/> </field> <field name="relatDateRetour" type="date" required="false" direct="false" transient="false"> <bind-xml name="relatDateRetour" node="element"/> </field> <field name="relatDateValfin" type="date" required="false" direct="false" transient="false"> <bind-xml name="relatDateValfin" node="element"/> </field> <field name="localite" type="string" required="false" direct="false" transient="false"> <bind-xml name="localite" node="element"/> </field> <field name="designation" type="string" required="false" direct="false" transient="false"> <bind-xml name="designation" node="element"/> </field> <field name="relatDateValdeb" type="date" required="false" direct="false" transient="false"> <bind-xml name="relatDateValdeb" node="element"/> </field> <field name="description" type="string" required="false" direct="false" transient="false"> <bind-xml name="description" node="element"/> </field> </class> <class name="lu.etat.culture.patsi.reserv.CollReser" auto-complete="false"> <description>Default mapping for class lu.etat.culture.patsi.reserv.CollReser</description> <map-to xml="collReser"/> <field name="relatValLocation" type="double" required="false" direct="false" transient="false"> <bind-xml name="relatValLocation" node="attribute"/> </field> <field name="collId" type="long" required="false" direct="false" transient="false"> <bind-xml name="collId" node="attribute"/> </field> <field name="nbObj" type="long" required="false" direct="false" transient="false"> <bind-xml name="nbObj" node="attribute"/> </field> <field name="relatRetour" type="integer" required="false" direct="false" transient="false"> <bind-xml name="relatRetour" node="attribute"/> </field> <field name="collDescription" type="string" required="false" direct="false" transient="false"> <bind-xml name="collDescription" node="element"/> </field> <field name="objListe" type="lu.etat.culture.patsi.collection.Objet" required="false" direct="false" transient="false" collection="array"> <bind-xml name="objListe" node="element"/> </field> <field name="relatComment" type="string" required="false" direct="false" transient="false"> <bind-xml name="relatComment" node="element"/> </field> <field name="collDateValfin" type="date" required="false" direct="false" transient="false"> <bind-xml name="collDateValfin" node="element"/> </field> <field name="relatDateRetour" type="date" required="false" direct="false" transient="false"> <bind-xml name="relatDateRetour" node="element"/> </field> <field name="relatDateValfin" type="date" required="false" direct="false" transient="false"> <bind-xml name="relatDateValfin" node="element"/> </field> <field name="collPermanent" type="string" required="false" direct="false" transient="false"> <bind-xml name="collPermanent" node="element"/> </field> <field name="collDateValdeb" type="date" required="false" direct="false" transient="false"> <bind-xml name="collDateValdeb" node="element"/> </field> <field name="relatDateValdeb" type="date" required="false" direct="false" transient="false"> <bind-xml name="relatDateValdeb" node="element"/> </field> </class> </mapping> **********************************************************
The XML message I want to unmarshall...
********************************************************** <resEmbargo xsi:type="xsd:integer">1</resEmbargo> <resType>embargo</resType> <resRaison>toto</resRaison> <resDateDebut>2003-10-15T00:00:00.000+02:00</resDateDebut> <resDateFin>2003-10-25T00:00:00.000+02:00</resDateFin> <objets> <item> <relatDateValdeb>2003-10-16T00:00:00.000+02:00</relatDateValdeb> <relatDateValfin>2003-10-24T00:00:00.000+02:00</relatDateValfin> <relatValLocation>12.12</relatValLocation> <relatRetour>1</relatRetour> <relatDateRetour>2003-10-25T00:00:00.000+02:00</relatDateRetour> <relatComment>Quel b� commentaire que voil�</relatComment> <objId>21</objId> <designation>Un bo�te d'allumettes</designation> <categorie>Bo�te en carton</categorie> </item> </objets> <contacts> <item> <relatDateValdeb>2003-10-12T00:00:00.000+02:00</relatDateValdeb> <relatDateValfin>2003-10-13T00:00:00.000+02:00</relatDateValfin> <relatRole>Clown de service</relatRole> <relatComment>Un bien joli contact en effet</relatComment> <cntsAdr1/> <cntsAdr2/> <cntsBureau/> <cntsCivilite>CIVI_0000001</cntsCivilite> <cntsCodpos/> <cntsDep/> <cntsEmail/> <cntsEntite/> <cntsEtat/> <cntsExtension/> <cntsFax/> <cntsGsm/> <cntsId>66</cntsId> <cntsNom>Hello</cntsNom> <cntsPays>PAYS_000001</cntsPays> <cntsPhone/> <cntsPrenom>brownie</cntsPrenom> <cntsPublLevel>0</cntsPublLevel> <cntsQual>E</cntsQual> <cntsTitre/> &! nbsp; <cntsVille/> <paysLib>Luxembourg</paysLib> </item> </contacts> </reservation> **********************************************************
The "wrong" result after marshalling process ........
**********************************************************
<reservationReturn> <reservation resEmbargo="0" resId="-1" travId="-1"> <resDateFin>2003-10-25T00:00:00.000+02:00</resDateFin> <objets> <objReser objId="-1" relatRetour="0" relatValLocation="0.0"> <categorie>Bo�te en carton</categorie> <relatComment>Quel b� commentaire que voil�</relatComment> <relatDateRetour>2003-10-25T00:00:00.000+02:00</relatDateRetour> <relatDateValfin>2003-10-24T00:00:00.000+02:00</relatDateValfin> <designation>Un bo�te d'allumettes</designation> <relatDateValdeb>2003-10-16T00:00:00.000+02:00</relatDateValdeb> </objReser> <objReser objId="-1" relatRetour="0" relatValLocation="0.0"> <relatComment>Un bien joli contact en effet</relatComment> <relatDateValfin>2003-10-13T00:00:00.000+02:00</relatDateValfin> <relatDateValdeb>2003-10-12T00:00:00.000+02:00</relatDateValdeb> </objReser> </objets> <resRaison>toto</resRaison> <contacts/> <resType>embargo</resType> <resDateDebut>2003-10-15T00:00:00.000+02:00</resDateDebut> </reservation> </reservationReturn> |
