[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jibx-users
Subject:    Re: [jibx-users] All child components must define element names
From:       Dennis Sosnoski <dms () sosnoski ! com>
Date:       2010-02-04 23:01:50
Message-ID: 4B6B51DE.7030303 () sosnoski ! com
[Download RAW message or body]

Thanks for replying to this, Darin, and your reply is correct. There's a 
way around this issue of needing a separate element name wrapping a 
collection, though, if you're only doing input.

Instead of defining the repeated elements as a collection, just define 
them as simple values with set-methods. Then with allow-repeats="true" 
on the containing <structure> the set-method will be called repeatedly 
for each time the element is seen.

That only works for unmarshalling, though. If you need to be able to 
marshal out documents as well you'd need to define a separate binding 
(with a <collection>, and without the flexible="true") for that side of 
things.

  - Dennis

Dennis M. Sosnoski
XML and Web Services in Java
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117



Darin Clark wrote:
>
> Ehm.  Like the error message says, all child components must define 
> element names for flexible='true' - and you haven't done that.
>
>  
>
> Take a look at your collection elements - you've got them linked to a 
> field in the object, but not linked to a /name/ in the XML.  While the 
> items inside the collection will have names, the collection itself 
> doesn't.
>
>  
>
> You need a structure that ends up in XML more like:
>
> <collection-name>
>
>                 <repeating-element/>
>
>                 <repeating-element/>
>
> </collection-name>
>
>  
>
> for flexible to work.  This can be an incredible pain in some 
> situations, and can prevent you from using flexible at all if you 
> don't have control over the XML...  As long as you control the XML, 
> here, though, all you need to do is name your two collections, and 
> that should work.
>
>  
>
> --
>
> The cake is a lie!
>
>  
>
> *From:* kashyap.shankhavara@zapak.com 
> [mailto:kashyap.shankhavara@zapak.com]
> *Sent:* Tuesday, January 12, 2010 4:46 AM
> *To:* jibx-users@lists.sourceforge.net
> *Subject:* [jibx-users] All child components must define element names 
> forflexible='true'; - [SPAM : E3 : Header ] - Email found in subject
>
>  
>
> Getting following error
>
>  
>
> *All child components must define element names for flexible='true';*
>
> <Body>
>  <Records>2</Records>
>  <Indicator>A</Indicator>
>  <ByOrAgainst>B</ByOrAgainst>
>  //Unknow elements
>  <Trade> <!-- Multiple -->
>   <Version>1</Version>
>   <BuySell>SELL</BuySell>
>   <Type>COMM</Type>
>   <SettlementDate>20100114</SettlementDate>
>   //Unknow elements
>   <Party>
>    <Type>xxx</Type>
>    <Value>xxxx</Value>
>    //Unknow elements
>    <Name>xxx xxx xxx xxx</Name><!-- Multiple -->
>    <Name>xxx xxx xxx</Name>
>   </Party>
>  </Trade>
> </Body>
>
>  
>
> <structure name="Body" ordered="false" *flexible="true">*
>  <value name="Records" field="records" />
>  <value name="Indicator" field="indicator" usage="optional" />
>  <value name="ByOrAgainst" field="byOrAgainst" />
>  <*collection* field="trade" usage="optional">
>   <structure name="Trade" type="com.bean.Trade" usage="optional"
>   * flexible="true"* ordered="false" allow-repeats="true">
>    <value name="Version" field="version" />
>    <value name="BuySell" field="buySell" />
>    <value name="Type" field="type" />
>    <value name="SettlementDate" field="settlementDate" />
>    <structure name="Party" field="party" type="com.bean.Party"
>    * flexible="true"* ordered="false">
>     <value name="Type" field="Type" />
>     <value name="Value" field="Value" />
>     <*collection *field="name" usage="optional">
>      <value name="Name" type="java.lang.String"
>       usage="optional" />
>     </collection><!-- End of Party-name -->
>    </structure><!-- End of Party -->
>   </structure>
>  </collection><!-- End of Trade -->
> </structure><!--End Body-->
>
> Any help is highly appreciated
>
>
>
> -----------------------------------------------------------------
> Get your free Email ID at www.zapakmail.com now!H
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> ------------------------------------------------------------------------
>
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>   

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic