wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes Creating Jibx Bindings for Ambiguous XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Creating Jibx Bindings for Ambiguous XML" Watch "Creating Jibx Bindings for Ambiguous XML" New topic
Author

Creating Jibx Bindings for Ambiguous XML

Jon Wilk
Greenhorn

Joined: Oct 22, 2009
Posts: 1
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.
krishna kanthgaru
Greenhorn

Joined: Feb 12, 2007
Posts: 17
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.


no signature ... i am not a celebrity yet
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating Jibx Bindings for Ambiguous XML
 
Similar Threads
Why qualified XML elements are erroring out ?
complexType can be root element?
ANY, anyType, &lt;xsd:any&gt;
How to generate JAXB Bindings for the xml element definition which is extending from other xml
XML design question