RE: XMLSpy and recursive schemas

Hi Ross:

Thanks for your help! It seems my being new to XMLSpy caused all the
trouble. Apparently, the original schema definition is ok and I finally
managed to get it to work - well, it's not perfect in that XMLSpy keeps
drawing different graphics on alternate nestings of <section> but the end
result of the XML file is correct so I'm leaving it at that. Maybe if I used
your definition, it may change but right now I'm not up to it.

So, thanks again and sorry about the trouble,

Mahesh


-----Original Message-----
From: Ross Thompson [mailto:ross@contivo.com]
Sent: Monday, July 01, 2002 6:24 PM
To: URSEKAR@contivo.com,MAHESH (Non-HP-Spain@contivo.com, ex2)
Cc: 'xmlschema-dev@w3.org'
Subject: 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:46:02 UTC