Is there an indicator or constraint on the root element?


Is there a standard way to indicate which of the top-level defined elements
in the Schema is the 
real root element in the instance XML document? And this indication can be
catched by a program
when processing only the Schema. And is there a constraint that other
top-level defined elements,
if not root element in the instance XML document, must be referred by later
defined elements?

For example, consider this Schema file and suppose there is no instance XML
files available:

	<xsd:schema xmlns:xsd="">

	 <xsd:element name="purchaseOrder" type="PurchaseOrderType"/>

	 <xsd:element name="comments" type="xsd:string"/>

	 <xsd:complexType name="PurchaseOrderType">
	   <xsd:element name="shipTo" type="Address"/>
	   <xsd:element name="billTo" type="Address"/>
	   <xsd:element ref="comments" minOccurs="0"/>
	   <xsd:element name="items"  type="Items"/>
	  <xsd:attribute name="orderDate" type="xsd:date"/>

	 <xsd:complexType name="Address">
	   <xsd:element name="name"   type="xsd:string"/>
	   <xsd:element name="street" type="xsd:string"/>
	   <xsd:element name="city"   type="xsd:string"/>
	   <xsd:element name="state"  type="xsd:string"/>
	   <xsd:element name="zip"    type="xsd:decimal"/>
	  <xsd:attribute name="country" use="fixed" value="US"/>

	 <xsd:complexType name="Items">
	   <xsd:element name="item" minOccurs="0" maxOccurs="unbounded">
	      <xsd:element name="productName" type="xsd:string"/>
	      <xsd:element name="quantity">
	        <xsd:restriction base="xsd:positiveInteger">
	         <xsd:maxExclusive value="100"/>
	      <xsd:element name="price"    type="xsd:decimal"/>
	      <xsd:element ref="comments"   minOccurs="0"/>
	      <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>
	     <xsd:attribute name="partNum" type="xsd:string"/>


It seems there is not way to tell whether it is "purchaseOrder"or "comments"
the real root element
in the instance XML file. 

Any suggestion and explaination will be greatly appreciated.


Received on Wednesday, 7 March 2001 12:09:09 UTC