Thomas,

Have you tried the CVS version? It should be working with the CVS
version. Some changes went in about a 5-6 weeks ago related to IDREFS.

Anyway, my test cases are definately working with the CVS version, and
they are set up in a similar fashion as yours.

Thanks,

--Keith

Thomas Louis wrote:
> 
> Hello,
> 
> Okay, I try it once more:
> Can anyone provide me an example where he used IDREFS successfully in
> unmarshalling an XML-file to an object-tree?
> 
> Best regards,
> Thomas
> 
> > -----Urspr�ngliche Nachricht-----
> > Von: Thomas Louis [mailto:[EMAIL PROTECTED]]
> > Gesendet: Donnerstag, 26. September 2002 10:23
> > An: [EMAIL PROTECTED]
> > Betreff: Re: [castor-dev] Unmarshal IDREFS
> >
> >
> > Hello Keith,
> >
> > I'm sure you mean
> >
> > ...
> > > <class name="Article" ...>
> > >   ...
> > >    <field name="categories" type="Category" collection="array" ...>
> > >       <bind-xml node="attribute" reference="true"/>
> > >    </field>
> > >   ...
> > > </class>
> >
> > Cause reference is an attribute of <bind-xml/>.
> > My code and mapping looks exactly like you posted, but the
> > Unmarshalling always ends up with the following exception:
> >
> > java.lang.IllegalArgumentException: array element type mismatch
> >       at java.lang.reflect.Array.set(Native Method)
> >       at
> > org.exolab.castor.mapping.loader.J1CollectionHandlers$1.add(Unknown
> > Source)
> >       at
> > org.exolab.castor.mapping.loader.FieldHandlerImpl.setValue(Unknown
> > Source)
> >       at
> > org.exolab.castor.xml.UnmarshalHandler.processAttribute(Unknow
> > n Source)
> >       at
> > org.exolab.castor.xml.UnmarshalHandler.processAttributes(Unkno
> > wn Source)
> >       at org.exolab.castor.xml.UnmarshalHandler.startElement(Unknown
> > Source)
> >       at
> > org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1340)
> >       at
> > org.apache.xerces.validators.common.XMLValidator.callStartElem
> > ent(XMLVal
> > idator.java:1197)
> >       at
> > org.apache.xerces.framework.XMLDocumentScanner.scanElement(XML
> > DocumentSc
> > anner.java:1862)
> >       at
> > org.apache.xerces.framework.XMLDocumentScanner$ContentDispatch
> > er.dispatc
> > h(XMLDocumentScanner.java:1238)
> >       at
> > org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDo
> > cumentScan
> > ner.java:381)
> >       at
> > org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1035)
> >       at org.exolab.castor.xml.Unmarshaller.unmarshal(Unknown Source)
> >       at org.exolab.castor.xml.Unmarshaller.unmarshal(Unknown Source)
> >       at
> > sportbet.server.config.def.OptionsDefinitions.load(OptionsDefi
> > nitions.ja
> > va:56)
> >       at
> > sportbet.server.config.def.OptionsDefinitions.getInstance(Opti
> > onsDefinit
> > ions.java:96)
> >       at sportbet.client.test.Main.testConfigDef(Main.java:49)
> >       at sportbet.client.test.Main.main(Main.java:60)
> >
> > It seems that castor does not find the <category> elements
> > identified by their id-attribute. Castor does not make a
> > reference to them. I can post the code if noone knows the
> > problem. I've attachet the mapping and a sample xml-file.
> >
> > Thanks,
> > Thomas
> >
> >
> > > -----Urspr�ngliche Nachricht-----
> > > Von: Keith Visco [mailto:[EMAIL PROTECTED]]
> > > Gesendet: Mittwoch, 25. September 2002 18:46
> > > An: [EMAIL PROTECTED]
> > > Betreff: Re: [castor-dev] Unmarshal IDREFS
> > >
> > >
> > >
> > >
> > > Hi Thomas,
> > >
> > > You can use something like the following :
> > >
> > > <class name="Category" identity="id" ...>
> > >    ...
> > >    <field name="id" ...>
> > >      <bind-xml node="attribute"/>
> > >    </field>
> > >    ...
> > > </class>
> > >
> > > <class name="Article" ...>
> > >   ...
> > >    <field name="categories" type="Category" collection="array"
> > > reference="true" ...>
> > >       <bind-xml node="attribute"/>
> > >    </field>
> > >   ...
> > > </class>
> > >
> > > Note the use of the 'identity' and 'reference' attributes.
> > >
> > > --Keith
> > >
> > > Thomas Louis wrote:
> > > >
> > > > Hello,
> > > >
> > > > Is it possible to unmarshall the following xml
> > > >
> > > > <shop>
> > > >         <category id="food"/>
> > > >         <category id="vegetarian"/>
> > > >         <category id="pizza"/>
> > > >
> > > >         <article categories="food vegetarian pizza">Pizza
> > > > Funghi</article>
> > > >         ...
> > > > </shop>
> > > >
> > > > To an object-tree like that:
> > > >
> > > > Class Shop {
> > > >         Category[] categories;
> > > >         Article[] articles;
> > > >         ...
> > > > }
> > > >
> > > > Class Category {
> > > >         String id;
> > > >         ...
> > > > }
> > > >
> > > > Class Article {
> > > >         Category[] categories;
> > > >         String desc;
> > > >         ...
> > > > }
> > > >
> > > > I hope you can imagine what I mean. I didn't get castor to
> > > create the
> > > > Article.categories array on unmarshalling. How must the
> > > mapping-file
> > > > look like?
> > > >
> > > > Thanks,
> > > > Thomas
> > > >
> > > > -----------------------------------------------------------
> > > > 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
> > >
> >
> >
> >
> 
> -----------------------------------------------------------
> 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