The problem must be something else. Please take a look at the
structure-binding tutorial at

http://jibx.sourceforge.net/tutorial/binding-structures.html#intro

A quote:

"[...] the structure of your objects is not tied to the structure of the
XML - you can restructure your object classes without needing to change
the XML format [...]"

In fact the original binding provided by Joel seems correct to me.
Leaving out the "field" attribute of a "structure" element does exactly
what is desired: It defines an element existent in XML for which no
corresponding field does exist in the Java code.

Joel, could you provide some more details on the error you encounter
(stack trace...)?

Best regards,

Tilman



Stephane Elie wrote:
> My guess is that the default (un)marshaller doesn't support this.
> You can do what you want by creating a custom (un)marshaller.
> http://jibx.sourceforge.net/tutorial/binding-custom.html
> <http://jibx.sourceforge.net/tutorial/binding-custom.html>
>
>
> On 11/23/06, [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>     Yes. The problem is that I can't change the source xml and I would
>     like
>     to keep also the same Java. Is there anything that I can change in the
>     binding.xml? Can I use "a" for root mapping instead of "p"?
>
>     Thanks.
>
>     On Wed, 22 Nov 2006 22:51:31 -0500, "Stephane Elie"
>     <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> said:
>     > Hi Joel,
>     >
>     > You have a mismatch between XML vs mapping vs Java, if I assume
>     that the
>     > Java is OK (because the XML is invalid), here are the
>     appropriate XML and
>     > mapping for it:
>     > This is untested so it may contain mistakes, let me know if this
>     is the
>     > case.
>     >
>     > The source xml:
>     > <p>
>     >     <c>0</c>
>     >     <d>Success</d>
>     > </p>
>     >
>     > The binding file:
>     > <binding>
>     >     <mapping class="Response" name="p">
>     >          <value name="c" field="code" />
>     >          <value name="d" field="desc" />
>     >     </mapping>
>     > </binding>
>     >
>     > Stephane
>     >
>     > On 11/22/06, [EMAIL PROTECTED]
>     <mailto:[EMAIL PROTECTED]> <[EMAIL PROTECTED]
>     <mailto:[EMAIL PROTECTED]>> wrote:
>     > >
>     > > Hi All,
>     > >
>     > > This is what I have.
>     > >
>     > > The source xml:
>     > > <p>
>     > >     <a>
>     > >         <c>0</code>
>     > >         <d>Success</desc>
>     > >     </a>
>     > > </p>
>     > >
>     > > The binding file:
>     > > <binding>
>     > >     <mapping class="Response" name="p">
>     > >      <structure name="a">
>     > >          <value name="c" field="code" />
>     > >          <value name="d" field="desc" />
>     > >      </structure>
>     > >     </mapping>
>     > > </binding>
>     > >
>     > > The java class and call code:
>     > > public class Response {
>     > >     private int code = 10;
>     > >     private String desc = "Internal error";
>     > > }
>     > >
>     > > final IBindingFactory bFact =
>     > > BindingDirectory.getFactory(responseClass);
>     > > final IUnmarshallingContext context =
>     > > bFact.createUnmarshallingContext();
>     > > response = (IResponse)
>     > > context.unmarshalDocument(method.getResponseBodyAsStream (),
>     null);
>     > >
>     > > The mapping is not working because it tries to create an
>     Response with
>     > > an InnerClass "a" but it crashes because the Response Object
>     doesn't
>     > > have any "a" property.
>     > >
>     > > Any help/idea? TIA,
>     > >
>     > >      Joel
>     > >
>     > > --
>     > > --
>     > >
>     > >   [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>     > >
>     > > --
>     > > http://www.fastmail.fm - Or how I learned to stop worrying and
>     > >                           love email again
>     > >
>     > >
>     > >
>     -------------------------------------------------------------------------
>     > > Take Surveys. Earn Cash. Influence the Future of IT
>     > > Join SourceForge.net's Techsay panel and you'll get the chance
>     to share
>     > > your
>     > > opinions on IT & business topics through brief surveys - and
>     earn cash
>     > >
>     http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>     
> <http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV>
>     > > _______________________________________________
>     > > jibx-users mailing list
>     > > jibx-users@lists.sourceforge.net
>     <mailto:jibx-users@lists.sourceforge.net>
>     > > https://lists.sourceforge.net/lists/listinfo/jibx-users
>     > >
>     --
>
>       [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>
>     --
>     http://www.fastmail.fm <http://www.fastmail.fm> - I mean, what is
>     it about a decent email service?
>
>
>     -------------------------------------------------------------------------
>     Take Surveys. Earn Cash. Influence the Future of IT
>     Join SourceForge.net's Techsay panel and you'll get the chance to
>     share your
>     opinions on IT & business topics through brief surveys - and earn cash
>     http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>     
> <http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV>
>     _______________________________________________
>     jibx-users mailing list
>     jibx-users@lists.sourceforge.net
>     <mailto:jibx-users@lists.sourceforge.net>
>     https://lists.sourceforge.net/lists/listinfo/jibx-users
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> ------------------------------------------------------------------------
>
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>   


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to