Eitan, when I tried both of your samples below, I got this error from the binding compiler:
org.jibx.runtime.JiBXException: Unknown collection type with no add or store method defined at tag "collection"(line 5, col 34, in sample_binding.xml) What version of jibx are you running? (I'm running beta-3c) If the (still not officially released) alpha-4.0 code supports this feature, this will be a welcome one, since it's much more straightforward than the hack I've been using to get around this. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Eitan Suez Sent: Wednesday, March 16, 2005 12:53 PM To: [email protected] Subject: Re: [jibx-users] Optional collection you don't have to resort to using the 'optional' keyword to omit part of the xml while unmarshalling. the jibx documentation shows an example binding where a set of xml 'instructions' are skipped (in the structured mapping section of the tutorial). a collection or a structure that has no corresponding field on your java class can be mapped like this: <structure name="itemAttributes" field="_itemAttributes"> <collection name="actors" /> <value name="AudienceRating" field="rating" /> ... </structure> the lack of a corresponding "field" attribute on the collection will cause jibx to skip that xml. in your case there is no wrapping "actors" element around each actor child element. so the binding would have to be slightly different. <structure name="itemAttributes" field="_itemAttributes"> <collection item-type="Actor" /> <value name="AudienceRating" field="rating" /> ... </structure> / eitan On Mar 16, 2005, at 12:27 PM, Smuts, Aaron wrote: > I have an xml file that has more data than I want to map to my objects. > > I can skip singly occuring elements with a structure with just a name > that is marked optional. However, how can I handle unbounded elements > that I don't want to map? > > The Aws wsdl has lots of these. > http://aws-beta.amazon.com/AWSAlexa/AWSAlexa.wsdl > > For example, say I get an item like the one below back and I don't > want the actor element in the itemattributes section. I could put > three structures in, but then as soon as I get a movie with 4 actors > listed, it will break. > > <Item> > <ASIN>B00008DDXB</ASIN> > - > <SmallImage> > - > <URL> > http://images.amazon.com/images/P/B00008DDXB.01._SCTHUMBZZZ_.jpg > </URL> > <Height>60</Height> > <Width>34</Width> > </SmallImage> > - > <MediumImage> > - > <URL> > http://images.amazon.com/images/P/B00008DDXB.01._SCMZZZZZZZ_.jpg > </URL> > <Height>140</Height> > <Width>80</Width> > </MediumImage> > - > <LargeImage> > - > <URL> > http://images.amazon.com/images/P/B00008DDXB.01._SCLZZZZZZZ_.jpg > </URL> > <Height>475</Height> > <Width>272</Width> > </LargeImage> > - > <ItemAttributes> > <Actor>Daniel Radcliffe</Actor> > <Actor>Rupert Grint</Actor> > <Actor>Emma Watson (II)</Actor> > <AudienceRating>PG (Parental Guidance Suggested)</AudienceRating> > <Director>Chris Columbus</Director> > <Format>Color</Format> > <Format>Closed-captioned</Format> > <Format>NTSC</Format> > - > <Languages> > - > <Language> > <Name>English</Name> > <Type>Original Language</Type> > </Language> > </Languages> > - > <ListPrice> > <Amount>2499</Amount> > <CurrencyCode>USD</CurrencyCode> > <FormattedPrice>$24.99</FormattedPrice> > </ListPrice> > <NumberOfItems>1</NumberOfItems> > <ProductGroup>Video</ProductGroup> > <ReleaseDate>2004-06-01</ReleaseDate> > <Studio>Warner Home Video</Studio> > <TheatricalReleaseDate>2002-11-15</TheatricalReleaseDate> > <Title>Harry Potter and the Chamber of Secrets</Title> > <UPC>085392359134</UPC> > </ItemAttributes> > </Item> > > > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real > users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_ide95&alloc_id396&op=click > _______________________________________________ > jibx-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/jibx-users ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_ide95&alloc_id396&op=ick _______________________________________________ jibx-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jibx-users ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_ide95&alloc_id396&op=click _______________________________________________ jibx-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jibx-users
