The package "jibx-extras" includes a custom unmarshaller to handle this,
since it comes up quite a bit.  Your binding should look something like
this:

<binding name="..." class="...">
  <structure name="A" field="..." usage="optional">
     <value style="element" name="childA" field="..." />
     <value usage="optional" set-method="setIgnored"
get-method="getIgnored"
                marshaller="org.jibx.extras.DiscardElementMapper"
                unmarshaller="org.jibx.extras.DiscardElementMapper" />
  </structure>
</binding>

And, of course, you'll have to uglify the target class a little bit by
adding two methods:

     public void setIgnored( Object ignore )
     {
     }

     public Object getIgnored(  )
     {
       return null;
     }

This assumes that "extra" elements will appear at the end of the
structure, which is fairly common - if you anticipate that new elements
may be added "at random" anywhere in the middle, add the
'ordered="false"' attribute to the binding for structure "A"; there's a
performance hit here, so it should be avoided, but if you have no
choice, it does work.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Andy Yang
Sent: Friday, September 09, 2005 9:52 AM
To: [email protected]
Subject: [jibx-users] Ignoring unmapped XML during unmarshalling

Hi all,

Just wondering whether there was a way to have JiBX ignore any elements
it came across during unmarshalling it didn't have a mapping for.

For example, if I use JiBX to write software that handles a message
like:

<A>
  <childA>
</A>

and sometime later, the message gets extended:

<A>
  <childA>
  <xyz:newChild>
</A>

Would it be possible to configure JiBX to ignore the new child element?

Or is this generally considered bad practice?

Thanks,
Andy


        
                
______________________________________________________
Click here to donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle
Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing &
QA
Security * Process Improvement & Measurement *
http://www.sqe.com/bsce5sf
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to