W3C home > Mailing lists > Public > xmlschema-dev@w3.org > May 2007

Re: Defining recursive elements?

From: Andrew Welch <andrew.j.welch@gmail.com>
Date: Thu, 17 May 2007 15:45:58 +0100
Message-ID: <74a894af0705170745h727edd32h60be56e927145926@mail.gmail.com>
To: "Michael Kay" <mike@saxonica.com>
Cc: "Todd Moon" <tmrfcm@gmail.com>, xmlschema-dev@w3.org

On 5/17/07, Michael Kay <mike@saxonica.com> wrote:
> > Well it's a matter of taste, but if you use the venetian
> > blind style of schema then you wouldn't use element ref=""
> > much, but @type instead, eg:
> >
> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> >
> >   <xs:element name="part" type="part"/>
> >
> >   <xs:complexType name="part">
> >     <xs:sequence>
> >       <xs:element name="part" type="part" minOccurs="0"
> > maxOccurs="unbounded"/>
> >     </xs:sequence>
> >     <xs:attribute name="serial" type="xs:string"/>
> >   </xs:complexType>
> >
>
> I'm not sure it's just a matter of taste. It feels wrong to me to have two
> element declarations for element part, one global and one local, when all
> the part elements are the same. It gives the same answers as far as
> validation of instances is concerned, but it seems a messier component
> model, which could give you a messier translation into classes when you do
> data binding, for example (I don't know if that's actually the case).


In this simple case the russian doll style is probably better.  The
two mains "pros" in the venetian blind style are a single root element
and the type definition is exposed for reuse rather than hidden within
the nesting, which become more appealing when the complexity
increases. (well thats what I read when I was learning this a few
weeks ago...)

Should potential data-binding issues really affect the way you write
your schema though?  Surely the code-creation code should be able to
detect and cope with the style....
Received on Thursday, 17 May 2007 14:46:02 GMT

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