But what about an unknown child element ? In XML we can add new children or new element : normally this should'nt impact any program that use the part of its interest in such a XML message.
Is there a way to ignore *any* element that is not bound in the JIBX binding file, even if we don't know them at the time binding is done ?

Thanks, JC

Guillaume Pothier a écrit :
It seems there is a simpler solution: see figure 9 on this page:
http://jibx.sourceforge.net/tutorial/binding-structures.html

On 9/12/05, Davies, Joshua <[EMAIL PROTECTED]> wrote:
  
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

    


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users


  


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

This e-mail, and any file transmitted with it, is confidential and intended solely for the use of the individ ual or entity to whom it is addressed. If you have received this email in error, please contact the sende r and delete the email from your system. If you are not the named addressee you should not disseminate, distr ibute or copy this email.

For more information on Agence France-Presse, please visit our web site at http://www.afp.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



begin:vcard
fn:Jean-Christophe Garnier
n:Garnier;Jean-Christophe
org;quoted-printable:Agence France Presse;D=C3=A9partement Ing=C3=A9nierie
adr:;;4 rue de la Bourse;Paris;;75002;France
email;internet:[EMAIL PROTECTED]
title:Chef de projet
tel;work:01 40 41 81 69
x-mozilla-html:TRUE
version:2.1
end:vcard

Reply via email to