Re: Bug in XSV? ... reference without <import>

"Henry S. Thompson" wrote:
> 
> Sure there is -- just <import> the namespace, with no
> 'schemaLocation'.  You've now issued a promise that at runtime someone
> will supply types in that namespace (if indeed you use them), but that
> promise won't come due _until_ runtime.  No problem.

Awesome!  So, the weather station schema would look like this:

weather-station.xsd
----------------------------------------------------
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
            targetNamespace="http://www.weather-station.org"
            xmlns="http://www.weather-station.org"
            xmlns:s="http://www.sensor.org"
            elementFormDefault="qualified">
    <xsd:import namespace="http://www.sensor.org"/>
    <xsd:element name="weather-station">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="sensor" type="s:sensor_type" 
                             maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>
----------------------------------------------------

Note that the <import> element does not have a schemaLocation.  Each
application provides its own definition of sensor_type, e.g.,

london-sensors.xsd
----------------------------------------------------
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
            targetNamespace="http://www.sensor.org"
            xmlns="http://www.sensor.org"
            elementFormDefault="qualified">
    <xsd:simpleType name="sensor_type">
       <xsd:restriction base="xsd:string">
           <xsd:enumeration value="barometer"/>
           <xsd:enumeration value="thermometer"/>
           <xsd:enumeration value="anenometer"/>
           <xsd:enumeration value="hygrometer"/>
       </xsd:restriction>
    </xsd:simpleType>
</xsd:schema>

Instance documents will reference both schemas:

london-weather-station.xml
----------------------------------------------------
<?xml version="1.0"?>
<weather-station xmlns="http://www.weather-station.org"
      xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
      xsi:schemaLocation=
                "http://www.weather-station.org weather-station.xsd
                 http://www.sensor.org london-sensors.xsd">
    <sensor>thermometer</sensor>
    <sensor>barometer</sensor>
    <sensor>hygrometer</sensor>
    <sensor>anenometer</sensor>
</weather-station>
----------------------------------------------------

Do I now have a correct understanding? 

This is very powerful!  Thanks a lot Henry!  This is definitely going
into Best Practices!  /Roger

Received on Monday, 7 May 2001 17:19:56 UTC