XML Schema element validation order

Hello,

I'm following the example in the XML schema tutorial from the w3.org, however I can't understand the design method based on defining all elements and attributes  first, and then referring to them using the ref attribute:


<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
       
<!-- definition of simple elements -->
<xs:element name="orderperson" type="xs:string"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
<xs:element name="title" type="xs:string"/>
<xs:element name="note" type="xs:string"/>
<xs:element name="quantity" type="xs:positiveInteger"/>
<xs:element name="price" type="xs:decimal"/>
       
<!-- definition of attributes -->
<xs:attribute name="orderid" type="xs:string"/>
       
<!-- definition of complex elements -->
<xs:element name="shipto">
 <xs:complexType>
  <xs:sequence>
   <xs:element ref="name"/>
   <xs:element ref="address"/>
   <xs:element ref="city"/>
   <xs:element ref="country"/>
  </xs:sequence>
 </xs:complexType>
</xs:element>
<xs:element name="item">
 <xs:complexType>
  <xs:sequence>
   <xs:element ref="title"/>
   <xs:element ref="note" minOccurs="0"/>
   <xs:element ref="quantity"/>
   <xs:element ref="price"/>
  </xs:sequence>
 </xs:complexType>
</xs:element>
       
<xs:element name="shiporder">
 <xs:complexType>
  <xs:sequence>
   <xs:element ref="orderperson"/>
   <xs:element ref="shipto"/>
   <xs:element ref="item" maxOccurs="unbounded"/>
  </xs:sequence>
  <xs:attribute ref="orderid" use="required"/>
 </xs:complexType>
</xs:element>
       
</xs:schema>

The question is how can I identify the desired root element of the target document? I can see from the example it's the "shiporder" element, but why not the "orderto" or "shipto" or "item" elements that are previously defined ?

Thank you !

       
---------------------------------
The fish are biting.
 Get more visitors on your site using Yahoo! Search Marketing.
--0-1512336615-1176373481=:25933
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Hello,<br><br>I'm following the example in the XML schema tutorial from the w3.org, however I can't understand the design method based on defining all elements and attributes  first, and then referring to them using the ref attribute:<br><br><pre>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;<br>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;</pre>       <pre>&lt;!-- definition of simple elements --&gt;<br>&lt;xs:element name="orderperson" type="xs:string"/&gt;<br>&lt;xs:element name="name" type="xs:string"/&gt;<br>&lt;xs:element name="address" type="xs:string"/&gt;<br>&lt;xs:element name="city" type="xs:string"/&gt;<br>&lt;xs:element name="country" type="xs:string"/&gt;<br>&lt;xs:element name="title" type="xs:string"/&gt;<br>&lt;xs:element name="note" type="xs:string"/&gt;<br>&lt;xs:element name="quantity" type="xs:positiveInteger"/&gt;<br>&lt;xs:element name="price" type="xs:decimal"/&gt;</pre>       <pre>&lt;!-- definition of attributes
 --&gt;<br>&lt;xs:attribute name="orderid" type="xs:string"/&gt;</pre>       <pre>&lt;!-- definition of complex elements --&gt;<br>&lt;xs:element name="shipto"&gt;<br> &lt;xs:complexType&gt;<br>  &lt;xs:sequence&gt;<br>   &lt;xs:element ref="name"/&gt;<br>   &lt;xs:element ref="address"/&gt;<br>   &lt;xs:element ref="city"/&gt;<br>   &lt;xs:element ref="country"/&gt;<br>  &lt;/xs:sequence&gt;<br> &lt;/xs:complexType&gt;<br>&lt;/xs:element&gt;<br>&lt;xs:element name="item"&gt;<br> &lt;xs:complexType&gt;<br>  &lt;xs:sequence&gt;<br>   &lt;xs:element ref="title"/&gt;<br>   &lt;xs:element ref="note" minOccurs="0"/&gt;<br>   &lt;xs:element ref="quantity"/&gt;<br>   &lt;xs:element ref="price"/&gt;<br>  &lt;/xs:sequence&gt;<br> &lt;/xs:complexType&gt;<br>&lt;/xs:element&gt;</pre>       <pre>&lt;xs:element name="shiporder"&gt;<br> &lt;xs:complexType&gt;<br>  &lt;xs:sequence&gt;<br>   &lt;xs:element ref="orderperson"/&gt;<br>   &lt;xs:element ref="shipto"/&gt;<br>   &lt;xs:element
 ref="item" maxOccurs="unbounded"/&gt;<br>  &lt;/xs:sequence&gt;<br>  &lt;xs:attribute ref="orderid" use="required"/&gt;<br> &lt;/xs:complexType&gt;<br>&lt;/xs:element&gt;</pre>       <pre>&lt;/xs:schema&gt;</pre><br>The question is how can I identify the desired root element of the target document? I can see from the example it's the "shiporder" element, but why not the "orderto" or "shipto" or "item" elements that are previously defined ?<br><br>Thank you !<br><p>&#32;
      <hr size=1>The fish are biting.<br>
<a href="http://us.rd.yahoo.com/evt=49679/*http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php?o=US2140&cmp=Yahoo&ctv=Q107Tagline&s=Y&s2=EM&b=50"> Get more visitors</a> on your site using <a href="
http://us.rd.yahoo.com/evt=49679/*http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php?o=US2140&cmp=Yahoo&ctv=Q107Tagline&s=Y&s2=EM&b=50">Yahoo! Search Marketing.</a>
--0-1512336615-1176373481=:25933--

Received on Friday, 13 April 2007 02:01:38 UTC