Re: Who's correct - XSV or XML Spy? [Was Re: Current Status of XSV: shadowing of elementFormDefault]

"Roger L. Costello" <costello@mitre.org> writes:

> [Sorry to be so stupid about this issue.  The differences that I am
> getting in the schema validators has thrown me into a state of
> confusion.  An answer to below example will straighten me out.]
> 
> Example.  I have 4 schemas, all in the same namespace
> (http://www.camera.org).  The schemas are: Camera.xsd, Nikon.xsd,
> Olympus.xsd, and Pentax.xsd.  The Camera schema includes the other three
> schemas.  Here's the four schemas (note the different values for
> elementFormDefault in the schemas):
> 
> ------------------------------------------------------------------
> Camera.xsd
> 
> <?xml version="1.0"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
>         targetNamespace="http://www.camera.org"
>         xmlns="http://www.camera.org"
>         elementFormDefault="qualified">
>     <xsd:include schemaLocation="Nikon.xsd"/>
>     <xsd:include schemaLocation="Olympus.xsd"/>
>     <xsd:include schemaLocation="Pentax.xsd"/>
>     <xsd:element name="camera">
>         <xsd:complexType>
>              <xsd:sequence>
>                  <xsd:element name="body" type="body_type"/>
>                  <xsd:element name="lens" type="lens_type"/>
>                  <xsd:element name="manual_adapter" 
>                               type="manual_adapter_type"/>
>             </xsd:sequence>
>         </xsd:complexType>
>     </xsd:element>
> </xsd:schema>
> ------------------------------------------------------------------
> 
> Nikon.xsd
> 
> <?xml version="1.0"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
>         targetNamespace="http://www.camera.org"
>         xmlns="http://www.camera.org"
>         elementFormDefault="unqualified">
>     <xsd:complexType name="body_type">
>         <xsd:sequence>
>             <xsd:element name="description" type="xsd:string"/>
>         </xsd:sequence>
>     </xsd:complexType>
> </xsd:schema>
> ------------------------------------------------------------------
> 
> Olympus.xsd
> 
> <?xml version="1.0"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
>         targetNamespace="http://www.camera.org"
>         xmlns="http://www.camera.org"
>         elementFormDefault="qualified">
>     <xsd:complexType name="lens_type">
>         <xsd:sequence>
>             <xsd:element name="zoom" type="xsd:string"/>
>             <xsd:element name="f-stop" type="xsd:string"/>
>         </xsd:sequence>
>     </xsd:complexType>
> </xsd:schema>
> ------------------------------------------------------------------
> 
> Pentax.xsd
> 
> <?xml version="1.0"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
>         targetNamespace="http://www.camera.org"
>         xmlns="http://www.camera.org"
>         elementFormDefault="unqualified">
>     <xsd:complexType name="manual_adapter_type">
>         <xsd:sequence>
>             <xsd:element name="speed" type="xsd:string"/>
>         </xsd:sequence>
>     </xsd:complexType>
> </xsd:schema>
> ------------------------------------------------------------------
> 
> The Camera and Olympus schemas indicates that all of their elements must
> be qualified.  The Nikon and Pentax schemas indicates that all their
> local elements must not be qualified.  Based upon that, I created this
> instance document:
> 
> <?xml version="1.0"?>
> <my:camera xmlns:my="http://www.camera.org"
>         xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
>         xsi:schemaLocation="http://www.camera.org Camera.xsd">
>     <my:body>
>         <description>Ergonomically designed blah blah</description>
>     </my:body>
>     <my:lens>
>         <my:zoom>300mm</my:zoom>
>         <my:f-stop>1.2</my:f-stop>
>     </my:lens>
>     <my:manual_adapter>
>         <speed>1/10,000 sec to 100 sec</speed>
>     </my:manual_adapter>
> </my:camera>
> 
> Note that the description element is a local element declared in
> Nikon.xsd and is not qualified, per elementFormDefault="unqualified" in
> Nikon.xsd.  Ditto for the speed element.  The other elements are
> qualified per elementFormDefault="qualified" in Camera.xsd and
> Olympus.xsd.
> 
> Here's the results of validating Camera.xml:
> 
> XSV - says it's valid (as does xerces and Oracle)
> XML Spy - says it's NOT valid, "This file is not valid: Mandatory
> element my:description expected in place of description".
> 
> Okay, who's right - XSV or XML Spy?  [My bet's on Henry]  /Roger

Not surprisingly, I think XSV is correct.  The spec. [1] makes clear
that what gets <include>d is components, not text, and those
components are 'constructed' in the context of the <include>d schema
document, so the <include>d schema document's defaults are operative.

ht

[1] http://www.w3.org/TR/xmlschema-1/#layer2
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/

Received on Saturday, 31 March 2001 07:13:08 UTC