XMLSpy and recursive schemas

URSEKAR,MAHESH (Non-HP-Spain,ex2) writes:
 > Hi!
 > 
 > I created the a schema that uses recurison using XML Spy. Here is the small
 > snippet that is giving me problems:
 > 
 > 	<xs:element name="sections">
 > 		<xs:complexType>
 > 			<xs:sequence>
 > 				<xs:element ref="section"
 > maxOccurs="unbounded"/>
 > 			</xs:sequence>
 > 		</xs:complexType>
 > 	</xs:element>
 > 	<xs:element name="section">
 > 		<xs:complexType>
 > 			<xs:sequence>
 > 				<xs:element ref="description"/>
 > 				<xs:element ref="repetitions"
 > minOccurs="0"/>
 > 				<xs:choice>
 > 					<xs:element ref="section"
 > maxOccurs="unbounded"/>
 > 					<xs:element ref="register"
 > maxOccurs="unbounded"/>
 > 				</xs:choice>
 > 			</xs:sequence>
 > 			<xs:attribute ref="name" use="required"/>
 > 			<xs:attribute ref="baseAddress" use="required"/>
 > 		</xs:complexType>
 > 	</xs:element>
 > 
 > Using XML Spy, I tried to create an XML document based on the above schema
 > and end up with the following problem: 
 > 
 > When I reach the "sections" element, XML Spy shows me the "section" element
 > as a sub-element. But the "section" element (which uses recursion) does not
 > show me any sub-children.  
 > 
 > I believe XML schemas support recursion. In that case, is this a limitation
 > with XMLSpy??
 > 
 > Any help would be welcome as this is a blocking problem in my current work!!

Every time I make a public statement on this list, I end up sticking
my foot in my mouth, so this time I will be cautious:

I believe it may possibly be somewhat true, at some time past, present
or future, that:

You cannot define elements or types in schema directly in terms of
themselves.  (Complex exception to muddy the water: this applies in a
very odd way when a 'redefine' is happening.)  Your example could be
fixed by making section's type a global type, viz:

  <xs:element name="section" type="section"/>

  <xs:complexType name="section">
    <xs:sequence>
      <xs:element ref="description"/>
      <xs:element ref="repetitions" minOccurs="0"/>
      <xs:choice>
        <xs:element ref="section" maxOccurs="unbounded"/>
        <xs:element ref="register" maxOccurs="unbounded"/>
      </xs:choice>
    </xs:sequence>
    <xs:attribute ref="name" use="required"/>
    <xs:attribute ref="baseAddress" use="required"/>
  </xs:complexType>

- Roß

---
Reality is an illusion that occurs due to the lack of alcohol.
					-- W.C. Fields

Received on Tuesday, 2 July 2002 04:45:47 UTC