• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating Jibx Bindings for Ambiguous XML

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My current project receives XML files and unmarshals them using JiBX. When unmarshaling a message, unknown attributes on an element are ignored, but any elements that are not expected cause parsing exceptions to occur.

The system that sends us the XML messages says that they are going to start sending us XML messages that could contain elements that our JiBX bindings are unaware of. Is there a way to ignore XML elements that JiBX isn't expecting?

Expected in Jibx Bindings:
<Customer name="SomeGuy" occuptation="developer"/>

Future XML:
<Customer name="SomeGuy" occupation="developer">
<telelphoneNumbers>
<PhoneNumber type="work" number="5555555555"/>
<PhoneNumber type="home" number="5555554444"/>
</telephoneNumbers>
</Customer>

In the future XML, we don't care about the telephone numbers, we just want to be able to parse the xml with the unexpected element in it.

Thanks.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
short answer yes. i am a newbie to jibx but i have faced the same problem.

you can make use jibx tags like

ordered="false"

allow-repeats="true"

usage="optional"

flexible="true" ( i believe this is what you are looking for in your example )

can refer to the docs at this site , http://jibx.sourceforge.net/ . quite useful.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I googled for JIBX and found a tutorial. On the third page of the tutorial it said

As of the JiBX 1.1 release, you have the option of ignoring unknown elements within an unordered group.



So it looks like the answer is "yes".
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic