Nicolas,
The problem is "most likely" occuring because Castor will create a
"default" map-to (it's not actually called map-to in memory, but rather
the xml name of the ClassDescriptor) for the test.addrBook.Port mapping.
During Unmarshalling Castor searches for a class that maps to the <Port>
element. Since you have two of them (PortExt - since you specified a
map-to of "Port" and the Port class itself), it probably just chooses
the first one it finds. My guess on the "intermittent" problems is that
the mapping stores it's mappings in a hashtable, so "order" is not
preserved, and hence you sometimes get the Port mapping used and
sometimes you get the PortExt mapping used for the <Port> element.
--Keith
Nicolas Christian wrote:
>
> I have a sporadic unmarshalling problem using the following specific mapping
> file:
>
> <class name="test.addrBook.Port" auto-complete="true" >
> </class>
> <!-- Extended class mapping -->
> <class name="test.addrBook.PortExt" auto-complete="false"
> extends="test.addrBook.Port" >
> <map-to xml="Port"/>
> </class>
>
> and my xml data are as follow:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Port>
> <name>port1</name>
> <number>12</number>
> <type>3</type>
> </Port>
>
> When i unmarshal the xml data using this mappingg file, sometime
> it works and a class PortExt is intanciated, and sometime it does
> not work and a class Port is instanciated by error.
>
> I have found a solution which avoid this problem, i have added the field
> 'map-to xml' in the description of the class Port. This added field is
> strictly needless for my application, but solves the problem.
>
> Hereafter, the new mapping solving the unmarsalling problem:
> <class name="test.addrBook.Port" auto-complete="true" >
> <map-to xml="Port_NotUsed"/>
> </class>
> <!-- Extended class mapping -->
> <class name="test.addrBook.PortExt" auto-complete="false"
> extends="test.addrBook.Port" >
> <map-to xml="Port"/>
> </class>
>
> After debbuging in the castor source, i think it might be a bug but i am not
> sure ?
> Is there anyone to confirm that...
> The only aim of this email is to point out this pecular unmarshalling
> problem,
> and help the users of castor xml.
>
> Christian
>
> <class name="test.addrBook.Port" auto-complete="true" >
> <!-- Warning: this 'map-to xml' is needless for the XMS project,
> -->
> <!-- but needed to avoid an unmarshalling castor bug
> -->
> <!-- for the extended classes, which occurs
> intermittenly.-->
> <!-- Never remove this 'map-to xml' description !
> -->
> <map-to xml="Port_NotUsed"/>
> </class>
> <!-- Extended class mapping -->
> <class name="test.addrBook.PortExt" auto-complete="false"
> extends="test.addrBook.Port" >
> <map-to xml="Port"/>
> </class>
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev