Print

Print


Based on schema logic, and at first blush, I think your second assertion 
is correct. A schema specifies what specific elements must contain, but 
not which elements must contain THEM. In other words, the schema 
validator looks down the tree, but not up or across the tree.

As a quick and dirty test, I created the following schema in oXygen:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="child" minOccurs="1"/>
            <xs:element ref="child2" minOccurs="1"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
   
<xs:element name="child"/>
<xs:element name="child2"/>
   
</xs:schema>

Then, I created the following instance document:

<?xml version="1.0" encoding="UTF-8"?>
<child xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    
xsi:noNamespaceSchemaLocation="file:/C:/Documents%20and%20Settings/cmullin/My%20Documents/text.xsd"/>

Though the "root" element of my instance document (<child>) is defined 
as a required child element of <root>, there are no "down-tree" 
requirements for <child>. Thus, the document is valid with only <child>.

Bear in mind that this experiment was based on only the simplest of 
examples. Is there something I'm missing? I look forward to other 
responses...

Hope this has helped,
Casey

Jonathan Rochkind wrote:
> Anyone familiar with XML schemas (.xsd)?
>
> Can you help me figure something out. Is there something in the schema 
> that specifies what elements can serve as the 'root node'... or is any 
> element described in the schema avaialable for use as a 'root node', 
> and it'll still validate?
>
> Thanks for any tips.
>
> Jonathan

-- 
Casey A. Mullin
Discovery Metadata Librarian
Metadata Development Unit
Stanford University Libraries
650-736-0849 
[log in to unmask]
http://www.caseymullin.com