I was able to come up with a work around by altering my object model. However I still like to know the castor's solution for this since this must be a very common occurrence in java. If anyone has any insight into this please let me know. Thanks for your help Jerome.

 

Shawn

 

-----Original Message-----
From: Pastre Jerôme [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 15, 2004 9:42 AM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Using the reference attribute for xml mapping

 

I don't know the answer of your last question.

 

Maybe Keith Visco  could help you more ......

 

--Jerome

 

-----Message d'origine-----
De : Arvin, Shawn POP/Exch) [mailto:[EMAIL PROTECTED]
Envoyé : jeudi 15 avril 2004 15:06
À : '[EMAIL PROTECTED]'
Objet : Re: [castor-dev] Using the reference attribute for xml mapping

Hi Jerome,

Thank you for your response. I was able to get it working as you describe, my problem was that I missed the part that the node had to be set to attribute. But not I am facing a different problem. What happens when the field that is doing the referencing is actually referencing an interface, where you could have instances of different classes. What I am seeing here is that the unmarshalling to xml looks ok but I can't go back from xml to java objects. Here is an example of the way I defined my mapping:

 

    <class name=" ComplexType"  identity="qualifiedName" >

        <field name="qualifiedName" type="string"/>

    </class>

 

    <class name=" PrimitiveTypeEnum" identity="name" verify-constructable="false">

        <field name="name" type="string"/>

    </class>

 

    <class name=" Attribute">

        <field name="type" type="TypeDescriptor" >

            <bind-xml name="attr_type" node="attribute" reference="true"/>

        </field>

    </class>

 

 

Both ComplexType and PrimitiveTypeEnum classes implement the interface TypeDescriptor. The Attribute Class has an attribute "type" of type TypeDescriptor. I don't see how castor can determine from the xml output which class to instantiate since the only thing that it outputs for the attr_type is the value and no class info.

 

Thanks

 

Shawn

-----Original Message-----
From: Pastre Jerôme [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 15, 2004 6:13 AM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Using the reference attribute for xml mapping

 

Hi Shawn,

 

This an example of mapping file :

 

<class name="pack3.lE"   identity="leOid">
   <field name="leOid" >
           <bind-xml node="attribute"/>
   </field>        
</class>      

 

 <class name="pack3.aG"  >
       <field name="refLe" type="pack3.lE" >  
              <bind-xml reference="true" node="attribute"/>
       </field>    
</class>    

 

--Jerome

-----M essage d'origine-----
De : Arvin, Shawn POP/Exch) [mailto:[EMAIL PROTECTED]
Envoyé : mercredi 14 avril 2004 21:32
À : '[EMAIL PROTECTED]'
Objet : [castor-dev] Using the reference attribute for xml mapping

 

Hi,

I am using the xml mapping and trying to figure out how the "identity" and "reference" attributes are supposed to be used in a mapping file?

 

Thanks,

 

Shawn

Reply via email to