Stephan is right. Jibx does ignore attributes. Jibx rocks!!!

If the mapping is modified to

<binding>
    <mapping name="XYZ" class="Yxz">
        <structure name="IDENT" field="ident" flexible="true" 
ordered="false">
            <value name="DATEINAME" field="dateiname" />
            <value name="VERSION-TYP" field="versionTyp" />
        </structure>
    </mapping>
</binding>

the other attributes are ignored.

But when you marshall the object only the tags that jibx knows about 
will be available. So the xml is different after a round trip.

cheers
Varghese


Stephan Bourges wrote:
> Something doesn't sound right here.  You do not have to specify bbb in 
> JiBX.  You can ignore elements as specified in the 'Going Furthur' 
> section of the tutorial.  Here is the paragraph that might shed some 
> light:
>  
> As of the JiBX 1.1 release, you have the option of ignoring unknown 
> elements within an unordered group. To enable this behavior you need 
> to include a *flexible="true"* on the binding element containing the 
> group (the same place you set the *ordered="false"*). Also as of 1.1, 
> repeated elements within an unordered group will by default be treated 
> as an error when unmarshalling (so if the Figure 3 
> <file:///C:/development/jibx/docs/tutorial/binding-extras.html#figure3> 
> sample document had a second instance of the *<address>* element, for 
> instance, the runtime code would throw an exception). You can disable 
> this checking for repeated elements by using the 
> *allow-repeats="true"* attribute on the containing element. Both these 
> options can only be used in combination with *ordered="false"* - if 
> you're using an ordered group, JiBX expects the elements to be exactly 
> as specified. See the structure attribute 
> <file:///C:/development/jibx/docs/details/binding-attributes.html#structure> 
> description for full details on these options
>
> ------------------------------------------------------------------------
> *From:* [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] *On Behalf Of 
> *Daniel Reichlmeier
> *Sent:* Friday, March 30, 2007 6:45 AM
> *To:* JiBX users
> *Subject:* [jibx-users] Antwort: Re: Update: Marshalling Problem with 
> non specified tags
>
>
> Hello,
>
> this are non good news. It's a problem for the realisation of my 
> use-case that there's no possibility to ignore "unknown" attributes. 
> To set attributes as optional is a good idea, but you have to specify 
> them, even if you are not interested in them. And if somebody adds a 
> tag to the xml-file, the marshaller doesn't work.
>
>  May be you have a large xml-file with a couple of "main"-parts:
>
> <xxx>
> <aaa>
> ...
> </aaa>
> <bbb>
> ...
> </bbb>
> <ccc>
> ...
> </ccc>
> </xxx>
>
> and the data you are interested in is only in part aaa (in my case), 
> you have to specify the other parts too in the mapping file?
>
> Mmmh, maybe jibx might not be the right solution for me? OK, after 
> marshalling and unmarshalling you would not get excactly the same file 
> if ignoring tags while marshalling... but that doesn't matter for me...
>
> Thanks again for your help.
>
> You could specify the tags in the structure and specify them as
> optional. I dont think jibx has ignorable xml attributes.
> Also, since you have a root element 'XYZ' your xml must start with an
> <XYZ> tag.
>
> cheers
> Varghese C V
>
> Daniel Reichlmeier wrote:
> >
> > Hello,
> >
> > imagine i've created an xml file like this:
> >
> >         <IDENT>
> >                 <DATEINAME>filename</DATEINAME>
> >                 <VERSION-TYP>1234</VERSION-TYP>
> >                 <VERSION-INHALT/>
> >                 <DATUM/>
> >                 <BESCHREIBUNG/>
> >                
> > 
> <CNT-CHECKSUMME>85ad24d2b89c10cfd80003eebd8cd03d6d49dbbb</CNT-CHECKSUMME>
> >         </IDENT>
> >
> > my description in the mapping.xml is like this:
> >
> >         <mapping name="XYZ" class="Yxz">
> >                 <structure name="IDENT" field="ident">
> >                         <value name="DATEINAME" field="dateiname"/>
> >                         <value name="VERSION-TYP" field="versionTyp"/>
> >                 </structure>
> >                 ...
> >         </mapping>
> >
> > i'm getting an exception while marshalling the xml-file like this:
> >
> > org.jibx.runtime.JiBXException: Expected "IDENT" end tag, found
> > "VERSION-INHALT" start tag (line 8, col 20)
> >         at
> > 
> org.jibx.runtime.impl.UnmarshallingContext.parsePastCurrentEndTag(UnmarshallingContext.java:793)
>  
>
> >
> >         at Zdc.JiBX_mapping_unmarshal_1_0(Zdc.java)
> >         at JiBX_mappingZdc_access.unmarshal()
> >         at
> > 
> org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2538)
>  
>
> >
> >         at
> > 
> org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2681)
>  
>
> >
> >         at Main.main(Main.java:25)
> >
> > Normaly, this is an feature of xml that you can parse OVER unknown
> > attributes (maybe you are not interestest in these information). Why
> > does jibx not ignore unknown attributes?
> >
> > Thanks for your help.
> > ------------------------------------------------------------------------
> >
> > 
> -------------------------------------------------------------------------
> > 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
> > [email protected]
> > 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
> [email protected]
> 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
> [email protected]
> 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to