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

RE: Defining recursive elements?

From: Shlomo Yona <S.Yona@F5.com>
Date: Wed, 16 May 2007 13:59:46 -0700
Message-ID: <B546C312A37C12438A22154026CDC7E00159239A@exchfive.olympus.f5net.com>
To: "Todd Moon" <tmrfcm@gmail.com>, <xmlschema-dev@w3.org>
It sounds like something like this:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <xsd:element name="part">
      <xsd:complexType>
         <xsd:element ref="part" minOccurs="0" maxOccurs="unbounded"/>
         <xsd:attribute name="serial" type="xsd:string"/>
      </xsd:complexType>
   </xsd:element>
</xsd:schema>
 
Shlomo

________________________________

From: xmlschema-dev-request@w3.org on behalf of Todd Moon
Sent: Wed 5/16/2007 10:55 AM
To: xmlschema-dev@w3.org
Subject: Defining recursive elements?




I'm not sure if the subject is accurate, but I'm trying to author an
XSD that allows a certain complex type to be nested within itself to
an arbitrary depth.

A simple example would look like this:

<?xml version="1.0" encoding="utf-8" ?>
<part serial="00000001234">
  <part serial="00000001234">
    <part serial="00000001234">
    </part>
    <part serial="00000001234">
    </part>
    <part serial="00000001234">
      <part serial="00000001234">
      </part>
      <part serial="00000001234">
        <part serial="00000001234">
        </part>
      </part>
    </part>
  </part>
  <part serial="00000001234">
  </part>
</part>

Any "part" can contain any number of other parts.

Is it possible to validate this structure without putting an arbitrary
limit on the maximum depth?
Received on Wednesday, 16 May 2007 21:00:05 GMT

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