W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2002

which way is correct?

From: Y. Han <yhan@uwo.ca>
Date: Fri, 6 Sep 2002 12:17:01 -0400 (EDT)
Message-ID: <003601c255c1$5e92c000$28646481@greatmind>
To: <xmlschema-dev@w3.org>
I am writing a shema for my research.

I am confused with the syntax for the schema.
The XML instance I want looks like
<RAC>
    <Graph>
       <Priv>p1</Priv>
       <MRole>m1</MRole>
       <Role>R1<Role>
    </Graph>
</RAC>

Now I have two choices. The first one is
<!-- ********************* Define the whole structure ************** -->
<xsd:element name="RAC">
   <xsd:complexType>
     <xsd:sequence>
       <xsd:element name="Graph">
         <xsd:complexType>
             <xsd:sequence>
                  <xsd:element name="Priv" type="PrivilegeType" maxOccurs="unbounded" />
              <xsd:element name="MRole" type="MRoleType" minOccurs="1" maxOccurs="1" />
                <xsd:element name="Role" type="xsd:Name" maxOccurs="unbounded" />
             </xsd:sequence>
         </xsd:complexType>
       </xsd:element>
   </xsd:sequence>
  </xsd:complexType>
</xsd:element>


The second one is 
<!-- ********************* Define the whole structure ************** -->
<xsd:element name="RAC">
   <xsd:complexType>
     <xsd:sequence>
        <xsd:element name="Graph" type="GraphType" minOccurs="0" maxOccurs="1" />
     </xsd:sequence>
   </xsd:complexType>
</xsd:element>

<!-- ******************** Define Graph Type ***************** -->
<xsd:complexType name="GraphType">
 <xsd:sequence>
  <xsd:element name="Priv" type="PrivilegeType" maxOccurs="unbounded" />
  <xsd:element name="MRole" type="MRoleType" minOccurs="1" maxOccurs="1" />
  <xsd:element name="Role" type="xsd:Name" maxOccurs="unbounded" />
 </xsd:sequence>
</xsd:complexType>


The first one is nested , while the second is seperated. Which one is correct? or both are correct?

In the view of XML Spy, they looks different, becuase the second one is displayed as "a complex Type"

thanks,
Received on Friday, 6 September 2002 14:43:19 GMT

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