Hi Johan,

The unmarshalling error basically means that the code thought it had 
processed everything in the <owner> element content, but hadn't found 
anything to do with the <collectiontypeone> element. That's very 
strange, especially since you show the contained <structure> is required 
(meaning JiBX should find something to match it or will complain about 
it being missing).

So I'm not sure why you're getting the unmarshalling error, but your 
binding is unnecessarily complex and that might indirectly cause some 
problems. As you've outlined it, there's no need to even have the 
<mapping> elements for java.util.ArrayList and GenericCustomCollection 
present in the binding. You can just remove these, and also remove the 
extends="GenericCustomCollection" attribute from the two specific 
collection <mapping>s. JiBX will then use the runtime type of the 
collection instance to choose between <collectiontypeone> and 
<collectiontypetwo> when marshalling, and will use the element name to 
decide which to create when unmarshalling.

  - Dennis

Dennis M. Sosnoski
SOA 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



Johan Walters wrote:
> I run into an error when unmarshalling: Expected "owner" end tag, found
> "customcollectionone" start tag.
>
> I suspect I'm missing something. Let me elaborate. 
>
> Suppose I have four classes:
> -Owner
> -GenericCustomCollection extends ArrayList
> -SpecificCustomCollectionOne extends GenericCustomCollection
> -SpecificCustomCollectionTwo extends GenericCustomCollection
>
> Now, Owner has an attribute of type GenericCustomCollection (called
> 'collectionattr'. During run-time, the type of the collection may need
> to switch, hence either one of the non-abstract 'specific' collection
> types is assigned to the abstract 'generic' collection. 
>
> My binding looks like this: 
>
> <mapping class="java.util.ArrayList" name="arraylist"/>
> <mapping class="GenericCustomCollection"
>       extends="java.util.ArrayList" abstract="true"/>
> <mapping class="SpecificCustomCollectionOne"
>       extends="GenericCustomCollection" 
>       name="collectiontypeone">
>       <collection usage="required">
>               <structure map-as="SomeType"/>
>       </collection>
> </mapping>
> <mapping class="SpecificCustomCollectionTwo"
>       extends="GenericCustomCollection" 
>       name="collectiontypetwo">
>       <collection usage="required">
>               <structure map-as="SomeOtherType"/>
>       </collection>
> </mapping>
>
> <mapping class="Owner" name="owner">                  
>       <structure field="collectionattr" usage="required"/>
> </mapping>
>
> Marshalling works fine:
> <owner> <collectiontypeone> <sometype/> </collectiontypeone> </owner>
>
> However, I get the error message above when unmarshalling. What should
> I change in my binding? Or do I need a factory or something? Or doesn't
> that have to do with the problem?
>
> Hope you can help,
>
> Johan Walters
>
> (btw I changed classnames for clarity)
>
>
>
>
>
>  
> ____________________________________________________________________________________
> Never Miss an Email
> Stay connected with Yahoo! Mail on your mobile.  Get started!
> http://mobile.yahoo.com/services?promote=mail
>
> -------------------------------------------------------------------------
> 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