W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2001

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

From: Roger L. Costello <costello@mitre.org>
Date: Sat, 31 Mar 2001 06:48:33 -0500
Message-ID: <3AC5C411.635F8A2F@mitre.org>
To: xmlschema-dev@w3.org, costello@mitre.org
[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
Received on Saturday, 31 March 2001 06:48:16 GMT

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