Jonas Kongslund wrote: > > Hi > > Using the SourceGenerator on the XML Schema below creates code for a Project > class and a Task class. Given a Project object I can reach all associated > Task objects but not the other way around. What should I change in order to > achieve a bi-directional one-to-many reference? > > I have tried to add > <xsd:element ref="project"/> > to the task sequence. That won't work. That simply means to reference an element declaration, it's not an element reference. You need to add the following to the Task definition: If there is one project to be referenced: <xsd:attribute name="project" type="xsd:IDREF"/> If there is more than one project to be referenced: <xsd:attribute name="projects type="xsd:IDREFS"/> You also need to change in your Project definition: From: ><xsd:element ref="task" maxOccurs="unbounded" minOccurs="0"/> to: <xsd:attribute name="tasks" type="xsd:IDREFS"/> > The SourceGenerator goes into an endless loop which > eventually is aborted by a StackOverflowException or OutOfMemory exception. That's not good...we'll need to look into that, are you using the CVS version? --Keith > > <?xml version="1.0"?> > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > targetNamespace="http://www.kongslund.dk/test"> > > <xsd:element name="project"> > <xsd:complexType> > <xsd:sequence> > <xsd:element name="id" type="xsd:long"/> > <xsd:element name="name" type="xsd:string"/> > <xsd:element ref="task" maxOccurs="unbounded" minOccurs="0"/> > </xsd:sequence> > </xsd:complexType> > </xsd:element> > > <xsd:element name="task"> > <xsd:complexType> > <xsd:sequence> > <xsd:element name="id" type="xsd:long"/> > <xsd:element name="name" type="xsd:string"/> > </xsd:sequence> > </xsd:complexType> > </xsd:element> > > </xsd:schema> > > -- > Jonas Kongslund <[EMAIL PROTECTED]> XNS: =Jonas Kongslund > > When you want to change the world, you don't see the dawn by > getting up early - you see it by not sleeping through the night. > > ----------------------------------------------------------- > 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
