Hi Adnan,

You can make JiBX unmarshalling ignore element order, but it's not 
automatic. You'd need to structure things so that there's an element 
name on every component of the group of binding definitions you want to 
make unordered, and make them all optional. See 
http://jibx.sourceforge.net/binding/tutorial/binding-extras.html#mixing 
and 
http://jibx.sourceforge.net/binding/binding-attributes.html#structure 
for details.

Making this work with repeated elements is messy, but possible. You need 
to define a method that just adds a value to the collection, then define 
the element in the binding as though it only occurred once, using the 
add method as a set-method, and use allow-repeats='true' on the 
containing element of the binding. That way the method gets called for 
each instance of the repeated element, and they all get added to the 
collection. This also requires that you make the binding 
direction="input", too (if you need to go in both directions you need to 
use separate bindings - the existing binding can be used for output in 
this case).

Hope that helps,

- Dennis

Dennis M. Sosnoski
XML and Web Services in Java
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117



Adnan Jaswal wrote:
>
> Hi,
>
> I am trying to unmarshall the xml below:
>
> <ns2:GETSTATUS_RESPONSE 
> xmlns:ns2="http://rts.splwg.com/webservices/packets"; 
> xmlns:ns3="http://rts.splwg.com/webservices/fields";>
>
> <ns2:DBMS_STATUS><ns3:STATUS>UP</ns3:STATUS> </ns2:DBMS_STATUS>
>
> <ns2:REGION_STATUS><ns3:REGION>DEV</ns3:REGION><ns3:STATUS>UP</ns3:STATUS></ns2:REGION_STATUS>
>
> <ns2:GEOCODE_STATUS><ns3:STATUS>DOWN</ns3:STATUS> </ns2:GEOCODE_STATUS>
>
> <ns2:RESULT><ns3:RESULT>SUCCESS</ns3:RESULT></ns2:RESULT>
>
> </ns2:GETSTATUS_RESPONSE>
>
> But getting this exception:
>
> _org.jibx.runtime.JiBXException_: Expected 
> "{http://rts.splwg.com/webservices/packets}GEOCODE_STATUS"; start tag, 
> found "{http://rts.splwg.com/webservices/packets}REGION_STATUS"; start 
> tag (line 6, col 21)
>
> at 
> org.jibx.runtime.impl.UnmarshallingContext.throwStartTagNameError(_UnmarshallingContext.java:220_)
>
> Snippet from binding file:
>
> <mapping class="com.splwg.rts.webservices.packets.GETSTATUSRESPONSE" 
> name="GETSTATUS_RESPONSE">
>
> <structure map-as="ns3:DBMS_STATUS" get-method="getDBMSSTATUS" 
> set-method="setDBMSSTATUS" name="DBMS_STATUS"/>
>
> <structure map-as="ns3:GEOCODE_STATUS" get-method="getGEOCODESTATUS" 
> set-method="setGEOCODESTATUS" name="GEOCODE_STATUS"/>
>
> <collection get-method="getREGIONSTATUSs" 
> set-method="setREGIONSTATUSs" create-type="java.util.ArrayList">
>
> <structure map-as="ns3:REGION_STATUS" name="REGION_STATUS"/>
>
> </collection>
>
> <structure map-as="ns3:RESULT" get-method="getRESULT" 
> set-method="setRESULT" name="RESULT"/>
>
> <collection get-method="getERRORs" set-method="setERRORs" 
> create-type="java.util.ArrayList">
>
> <structure map-as="ns3:ERROR" name="ERROR"/>
>
> </collection>
>
> </mapping>
>
> If I edit the xml and change the order of the elements to be the same 
> as the binding file then I don’t get the exception e.g move 
> GEOCODE_STATUS before the REGION_STATUS.
>
> Is there a way I can tell the unmarshaller not to be strict with the 
> order of elements?
>
> Regards,
>
> Adnan
>
>
> ______________________________________________________________________
> This email and any attachments may contain privileged and confidential
> information and are intended for the named addressee only. If you have
> received this e-mail in error, please notify the sender and delete
> this e-mail immediately. Any confidentiality, privilege or copyright
> is not waived or lost because this e-mail has been sent to you in
> error. It is your responsibility to check this e-mail and any
> attachments for viruses. No warranty is made that this material is
> free from computer virus or any other defect or error. Any
> loss/damage incurred by using this material is not the sender's
> responsibility. The sender's entire liability will be limited to
> resupplying the material.
> ______________________________________________________________________
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate 
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
> lucky parental unit.  See the prize list and enter to win: 
> http://p.sf.net/sfu/thinkgeek-promo
> ------------------------------------------------------------------------
>
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>   

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to