W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2004

redefine questions

From: Xiaofeng Wang <xwang@xtensible.net>
Date: Thu, 30 Dec 2004 18:40:23 -0500
Message-ID: <4CE77B740A7EEC41B52DAB5991421BD303A223DD@ms06>
To: <xmlschema-dev@w3.org>
Hi All,

 

I have a cim base schema file:

 

cimBase2.xsd

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:cim="cimBase2"
xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="cimBase2"
elementFormDefault="qualified" attributeFormDefault="unqualified">

<xs:complexType name="Naming">

<xs:sequence>

<xs:element name="aliasName" type="xs:string" minOccurs="0"/>

<xs:element name="description" type="xs:string" minOccurs="0"/>

<xs:element name="name" type="xs:string" minOccurs="0"/>

<xs:element name="pathName" type="xs:string" minOccurs="0"/>

</xs:sequence>

</xs:complexType>

<xs:complexType name="Collection" mixed="false">

<xs:complexContent mixed="false">

<xs:extension base="cim:Naming">

<xs:sequence>

<xs:element name="collectionType" type="xs:string" minOccurs="0"/>

<xs:element name="collectionQuantity" type="xs:integer" minOccurs="0"/>

<xs:element name="currentStatus" type="xs:string" minOccurs="0"/>

</xs:sequence>

</xs:extension>

</xs:complexContent>

</xs:complexType>

</xs:schema>

 

I would like to redefine it as:

(1) Further restriction on name element and make it required

(2) Discard other elements from Naming

(3) Make collectionType, collectionQuantity, currentStatus required
elements

 

The redefine schema is:

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:cim="cimBase2" targetNamespace="cimBase2"
elementFormDefault="qualified">

<xs:redefine schemaLocation="cimBase2.xsd">

<xs:complexType name="Collection">

<xs:complexContent>

<xs:restriction base="cim:Collection">

<xs:sequence>

<xs:element name="name">

<xs:simpleType>

<xs:restriction base="xs:string">

<xs:enumeration value="Collection1"/>

<xs:enumeration value="Collection2"/>

</xs:restriction>

</xs:simpleType>

</xs:element>

<xs:element name="collectionType" type="xs:string" minOccurs="0"/>

<xs:element name="collectionQuantity" type="xs:integer"/>

<xs:element name="currentStatus" type="xs:string"/>

</xs:sequence>

</xs:restriction>

</xs:complexContent>

</xs:complexType>

</xs:redefine>

</xs:schema>

 

This is passed the schema validation using XMLSpy. But I still want to
make sure if it is a legal use of redefine because XMLSpy sometimes
gives me wired results.

 

I am pretty happy with what I have done above. But I would like to go
one step further:

 

I have another schema importing cimBase2 and have a different namespace,
ext

 

extBase.xsd

<?xml version="1.0" encoding="utf-8"?>

<xs:schema xmlns:cim="cimBase2" xmlns:ext="extBase"
xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="extBase"
elementFormDefault="qualified" attributeFormDefault="unqualified">

<xs:import namespace="cimBase2" schemaLocation="cimBase2.xsd"/>

<xs:complexType name="ActualLoad" mixed="false">

<xs:complexContent mixed="false">

<xs:extension base="cim:Naming">

<xs:sequence>

<xs:element name="timeInterval" type="xs:dateTime" minOccurs="0"/>

<xs:element name="qualityFlag" type="xs:string" minOccurs="0"/>

</xs:sequence>

</xs:extension>

</xs:complexContent>

</xs:complexType>

</xs:schema>

 

I would like to redefine it as:

(1)Further restrict name and make it required (2)Further restrict
aliasName and make it required (3)Make timeInterval, qualityFlag
required element

 

The redefine schema I came up with is:

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ext="extBase" xmlns:cim="cimBase2" targetNamespace="extBase"
elementFormDefault="qualified">

<xs:redefine schemaLocation="extBase.xsd">

<xs:complexType name="ActualLoad">

<xs:complexContent>

<xs:restriction base="ext:ActualLoad">

<xs:sequence>

<xs:element name="name">

<xs:simpleType>

<xs:restriction base="xs:string">

<xs:enumeration value="Load1"/>

<xs:enumeration value="Load2"/>

</xs:restriction>

</xs:simpleType>

</xs:element>

<xs:element name="aliasName">

<xs:simpleType>

<xs:restriction base="xs:string">

<xs:enumeration value="aliasLoad1"/>

<xs:enumeration value="aliasLoad2"/>

</xs:restriction>

</xs:simpleType>

</xs:element>

<xs:element name="timeInterval" type="xs:dateTime"/>

<xs:element name="qualityFlag" type="xs:string"/>

</xs:sequence>

</xs:restriction>

</xs:complexContent>

</xs:complexType>

</xs:redefine>

</xs:schema>

 

XMLSpy gave me wired validating result. If I use text mode, it didn't
pass. If I use Schema mode, it passed, but couldn't generate the sample
data. My questions are:

Is it a valid schema?

Did I use redefine right?

Is this possibly be done by redefine? I don't want to redefine the
original definition of Naming because it has cascading effect.

Any other validators are available?

 

Your help is highly appreciated.

 

Thanks a lot

Xiaofeng

 

 
Received on Friday, 31 December 2004 06:59:11 GMT

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