Re: Nested Elements in Schema

> > How can i nest a element say "forwardcomment" inside another element called
> > "forwardcomment" both being of the same type.
> >
> > Here is the kind of XML tree i wish to create
> >
> > <BaseComment>
> >       <responsecomment>ZZZZ</responsecomment>
> >       <forwardcomment>
> >               XXX
> >               <responsecomment>ZZZZ</responsecomment>
> >               <forwardcomment>
> >               XXX
> >                       <responsecomment>ZZZZ</responsecomment>
> >               </forwardcomment>
> >
> >       </forwardcomment>
> > </BaseComment>
> >
> > The nesting of the element "forwardcomment" is to be indefinite.
> >
> > Is it possible at all?
>
> Yes, definitely.
>
> To do so, the simplest is to create a global definition for
> "forwardcomment" and to reference it when you need it... something such as:
>
> <xs:element name="forwardcomment">
>   <xs:complexType mixed="true">
>    <xs:sequence>
>     <xs:element name="responsecomment" type="xs:string"/>
>     <xs:element ref="forwardcomment"/>
>    </xs:sequence>
>   </xs:complexType>
> </xs:element>

I could be wrong here but I think that the <xs:element ref="forwardcomment"> must
be made optional otherwise we create an infinate loop. So I believe it must be:

<xs:element name="forwardcomment">
  <xs:complexType mixed="true">
   <xs:sequence>
    <xs:element name="responsecomment" type="xs:string"/>
    <xs:element ref="forwardcomment" minOccurs="0"/>
   </xs:sequence>
  </xs:complexType>
</xs:element>

Cheers,
/Eddie

>
>
> > Any pointers or help would be highly appreciated.
>
> http://www.xml.com/pub/a/2000/11/29/schemas/part1.html
>
> Hope this helps.
>
> Eric
>
> >
> > Regards,
> > kartik
> >
>
> --
> Rendez-vous à Paris pour le Forum XML.
>                     http://www.technoforum.fr/Pages/forumXML01/index.html
> ------------------------------------------------------------------------
> Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
> http://xsltunit.org      http://4xt.org           http://examplotron.org
> ------------------------------------------------------------------------

Received on Wednesday, 17 October 2001 19:45:20 UTC