Hi Vasilis,

JiBX uses the element name when unmarshalling to determine the type of object to create (like all the other data binding frameworks I'm aware of), so you can't do what you want directly. Just from an XML standpoint, you really should use different element names when the content is different. If you can't change the XML structure, you could probably do something using a different Java class structure where you had a single ClientData class with a field referencing a separate object that contains the CardID/MotoId information.

 - Dennis

Vasilis wrote:

Sorry i have a mistake in my post
The testing file is this. The problem still exists...

<ClientData>
 <FirstandLastName>G.F</FirstandLastName>
 <mid>120</mid>
</ClientData>

And this is the exception:
When i execute the test code i get the following
exception: Expected: CarID start tag found: mid
start tag.

Vasilis wrote:

Hello all,

I am using JIBX to unmarshall an XML document. The problem i am facing is this:
I have created multiple mapping into the same
binding
like this:

<mapping class = "Client" abstract = "true">
 <stucture name ="FirstandLastName" field="name"/>
</mapping>
<mapping name="ClientData" class="carClients"
extends="Client">
  <structure map-as="Client"/>
  <stucture name="CarID">
  <value name="cid" field="id"/>
  </structure>
</mapping>
<mapping name="ClientData" class="motoClients"
extends="Client">
  <structure map-as="Client"/>
  <structure name="MotoId">
    <value name="mid" field="id"/>
  </structure>
</mapping>

The testing file i am using is this
<ClientData>
<FirstandLastName>G.F</FirstandLastName>
<MotoID>120</MotoID>
</ClientData>


When i execute the test code i get the following
exception: Expected CarID start tag found MotoId
start
tag.

I think this occurs because both two mappings are
extending the Client class and because they have
common tags(the ClientData tag) during the
unmarshalling wrong  mapping class is used. I have
noticed in the exception window that the class
"JiBX_Client_bindingcarClients_access.class" is used
When I reverse the last two mappings in the binding
the unmarshalling is done succefully.

How can i make it work?


        

        
                

___________________________________________________________
Χρησιμοποιείτε Yahoo!; Βαρεθήκατε τα ενοχλητικά μηνύματα (spam); Το Yahoo! Mail διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών μηνυμάτων http://login.yahoo.com/config/mail?.intl=gr




        

        
                
___________________________________________________________ Χρησιμοποιείτε Yahoo!; Βαρεθήκατε τα ενοχλητικά μηνύματα (spam); Το Yahoo! Mail διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών μηνυμάτων http://login.yahoo.com/config/mail?.intl=gr


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to