I think we have a language barrier issue! :-)

In any case...

References are currently supported as follows:

1. A reference must be made using an attribute <-- important!!!

2. An identity is an attribute (or element that only contains a value)


Assume I have a bar object with ID = 123, and a foo object that
references
the bar... such as:

<root>
    <bar id="123">
       ...
    </bar>

    <foo bar="123">
       ...
    </foo>
</root>


3. The referencing object must have the appropriate setters and getters:

public class Foo {
    
    public Bar getBar();
    public void setBar(Bar bar);
}


4. When marshalling a reference object it appears as an attribute just
   like the above example:

   <foo bar="123">
     ...
   </foo>

   Not as an element: <-- Important

   <foo>
     <bar id="123"/>
   </foo>

   In order to support the latter, we need to support container
elements, and
   we do not currently support container elements.

5. The mapping file must be as follows:

<class name="Bar" identity="id">
   ...
   <field name="id" type="string"/>
   ...
</class>

<class name="Foo">
   ...
   <field name="bar" type="Bar">
      <bind-xml node="attribute" reference="true"/>
   </field>
   ...
</class>


You cannot use node="element", because we do not support
container-elements yet.

Below in your example you try to use node="element" because you want:

> -      <MyAuftrag AuftragOID="1019738737354"/>

This is NOT supported as a reference, but we do support the following:

> <Auftragsposition AuftragspositionOID="1019738737353" MyAuftrag="1019738737354">

Notice that the MyAuftrag is an attribute, not an element. It will be
resolved into the proper MyAuftrag object.

As I've said in a number of postings in the past...references are
currently handled via attributes not elements.

It's basically very similar to ID/IDREF in a DTD...it's all done via
attributes.

My test cases are working properly...so I know it works!

I hope that clears it up.

--Keith




Chetan Rathi wrote:
> 
> Hello Keith,
> 
> As indicated in the XML document given below:
> 
> Auftragposition references its parent Auftrag.....
> 
> The current version of the XML document generated is as follows:
> 
> <Auftragsposition AuftragspositionOID="1019738737353">
> 
>         <betragBrutto>0.0</betragBrutto>
>         <betragOffen>0.0</betragOffen>
>     <Zahlungsart>B</Zahlungsart>
>         <TpGebiet>18</TpGebiet>
> -      <MyAuftrag AuftragOID="1019738737354">
> 
> <AuftragErteiltDatum>2002-04-25T14:45:38.000</AuftragErteiltDatum>
>              <ErfasstVon>0100002371</ErfasstVon>
>         </MyAuftrag>
>  </Auftragsposition >
> 
> We just want an reference to the auftrag object with the primary key
> being the auftragOID...
> and are expecting the resultant document to be some what like the
> foloowing...with a refernce to the auftrag with the auftragOID as an
> attribute...
> 
> <Auftragsposition AuftragspositionOID="1019738737353">
>         <betragBrutto>0.0</betragBrutto>
>         <betragOffen>0.0</betragOffen>
>     <Zahlungsart>B</Zahlungsart>
>         <TpGebiet>18</TpGebiet>
> -      <MyAuftrag AuftragOID="1019738737354"/>
>     </Auftragsposition >
> The mappinf wht i have used is:
> Mappinf content:
> 
> <class
> name="com.dekra.automobil.auftragswesen.pbo.vbsf.PBOVBSFAuftrag"
> identity="auftragOID">
>   <map-to xml="Auftrag"/>
>   <field name="auftragOID" type="java.lang.String">
>    <bind-xml name="AuftragOID" node="attribute"/>
>   </field>
> </class>
> 
> <class
> name="com.dekra.automobil.auftragswesen.pbo.vbsf.PBOVBSFAuftragsposition"
> identity="auftragspositionOID">
>   <map-to xml="Auftragsposition"/>
> <field name="MyAuftrag"
> type="com.dekra.automobil.auftragswesen.pbo.vbsf.PBOVBSFAuftrag"
> get-method="getMyAuftrag">
>    <bind-xml name="MyAuftrag" node="element" reference="true"/>
>   </field>
> </class>
> We are using the castor tool only for the marshalling and the
> unmarshalling of the java object model using the mapping file.
> I am using the CVS version :
> castor 0.9.3-jar file..
> The mapping.dtd indicates the reference and the identity tags...
> Kindly let me know the correct way of representing the same.....
> Does castor not support references???????
> I have laready posted the same query couple of times, i am yet to have
> a answer for the same.
> Your prompt response would highly be appreciated.
> 
> Regards,
> 
> Chetan Rathi
> Augsburger Str.336
> 70327 Stuttgart
> Tel no.0711-7861-3148(off.)
> Handy.no.015055564671
> 
> >From: Keith Visco
> >Reply-To: [EMAIL PROTECTED]
> >To: [EMAIL PROTECTED]
> >Subject: Re: [castor-dev]
> >Date: Fri, 30 Nov 2001 14:15:57 -0600
> >
> >
> >
> >Chetan Rathi wrote:
> > >
> > > Hello,
> > >
> > > In order to handle back references, i have implemented the
> > > reference="true" in the bind-xml tag.
> > >
> > > We have scenario :
> > >
> > > Auftrag class having 1:many relation ship with the auftrag
> position
> > > class.
> > >
> > > The following is the mapping file excerpt as reagards the above
> > > relationship:
> > >
> > > > >
> name="com.dekra.automobil.auftragswesen.pbo.vbsf.PBOVBSFAuftrag"
> > > identity="auftragOID" >
> > >
> > >
> > > > > set-method="setAuftragOID" get-method="getAuftragOID">
> > >
> > >
> > >
> > >
> > >
> > > > >
> name="com.dekra.automobil.auftragswesen.pbo.vbsf.PBOVBSFAuftragsposition"
> > >
> depends="com.dekra.automobil.auftragswesen.pbo.vbsf.PBOVBSFAuftrag">
> > >
> > >
> > > > >
> type="com.dekra.automobil.auftragswesen.pbo.vbsf.PBOVBSFAuftrag">
> > >
> > >
> > >
> > >
> > >
> > > I was checking the mapping.dtd file but couldt find the attribute
> > > reference in the above mentioned tag.
> > >
> >
> >Which version of Castor are you using?
> >
> >It's definately listed in the CVS version.
> >
> >If you are not using the CVS version I suggest you upgrade to that,
> it
> >may
> >solve the problems you are facing.
> >
> >--Keith
> >
> >-----------------------------------------------------------
> >If you wish to unsubscribe from this mailing, send mail to
> >[EMAIL PROTECTED] with a subject of:
> > unsubscribe castor-dev
> >
> 
> ----------------------------------------------------------------------
> Get your FREE download of MSN Explorer at http://explorer.msn.com.
> ----------------------------------------------------------- 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

Reply via email to