[prev in list] [next in list] [prev in thread] [next in thread]
List: jibx-users
Subject: Re: [jibx-users] TypedArrayMapper and inheritance problem
From: Dennis Sosnoski <dms () sosnoski ! com>
Date: 2004-09-22 5:05:39
Message-ID: 41510823.4050706 () sosnoski ! com
[Download RAW message or body]
One problem here appears to be that you're telling the TypedArrayMapper
to use an element <adresses> around the list of items present in that
array. When unmarshalling the <adresses> start tag is not found, so the
runtime thinks the whole (optional) array is not present in the
document. I don't know why that element would be missing, if the
document you showed was generated by marshalling with the same binding -
I suspect you actually generated it using a different binding definition.
Another problem is that you've got ordered="false" on your mapping for
subAdress, with two child elements both named "number". That probably
should be checked as an error by JiBX, but if you think about it you
should see that there's no way the runtime can tell which <number>
element is which. Generally you should stay with the default of
ordered="true" unless you really need unordered elements.
- Dennis
reto mueller wrote:
>Hi,
>
>I’m trying to write a binding that uses the
>org.jibx.extras.TypedArrayMapper to
>marshall/unmarshall an array of objects. The binding
>compiles OK when having the binding defined like this:
>
><binding>
> <mapping class="jibxtest.Person" name="person"
>ordered="false" >
> <value name="personNumber" field="personNumber"
>usage="optional"/>
> <structure field="adresses" usage="optional"/>
> </mapping>
>
> <mapping class="jibxtest.Adress" abstract="true"
>ordered="false" >
> <value name="number" field="number"
>usage="optional"/>
> </mapping>
>
> <mapping class="jibxtest.Adress[]" name="adresses"
>marshaller="org.jibx.extras.TypedArrayMapper"
>unmarshaller="org.jibx.extras.TypedArrayMapper" />
>
> <mapping class="jibxtest.SubAdress" name="subAdress"
> ordered="false" extends="jibxtest.Adress">
> <structure map-as="jibxtest.Adress"
>usage="optional"/>
> <value name="number" field="subNumber"
>usage="optional"/>
> </mapping>
></binding>
>
>While Adress is an superclass of subAdress and the
>Person contains an Array of adresses. At rutime I add
>subAdress objects to the Adrdess Array. Marshalling
>works but when I unmarshall the following xml:
>
><?xml version="1.0" encoding="UTF-8"?>
><person>
> <personNumber>personNumber</personNumber>
> <subAdress>
> <number>4</number>
> <number>subNumber1</number>
> </subAdress>
></person>
>
>I get an the following exception:
>org.jibx.runtime.JiBXException: Expected end tag,
>found start tag "number"
>
>Unmarshalling works too when I add <addresses> tags
>around the <subadress> by hand - but this is not a
>solution!
>
>does anyone have experience with the TypedArrayMapper
>and is able to help?
>
>
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
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