W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2001

Re: Nested Elements in Schema

From: Eddie Robertsson <eddie@allette.com.au>
Date: Thu, 18 Oct 2001 09:51:35 +1000
Message-ID: <3BCE1987.2457BE1C@allette.com.au>
To: Eric van der Vlist <vdv@dyomedea.com>
CC: kbisht@citadon.com, xmlschema-dev@w3.org
> > 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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:24 GMT