W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2002

Re: Codelists: restricting simpleContent complexTypes

From: Stefan Wachter <Stefan.Wachter@gmx.de>
Date: Wed, 16 Oct 2002 11:36:40 +0200 (MEST)
To: Simon.Cox@csiro.au;xmlschema-dev@w3.org;;
Message-ID: <27047.1034761000@www59.gmx.net>

Hi Simon.

Your schema and instance seem to be valid. I validated them using JBind
(http://www.jbind.org).

--Stefan


> 
> I want to build codelists in a uniform way, and have the authority for the
> code list available in the PSVI.  Here's a schema with some commentary:
> 
> =======================
> <schema targetNamespace="http://xmml.ned.dem.csiro.au/my"
> xmlns="http://www.w3.org/2001/XMLSchema"
> xmlns:my="http://xmml.ned.dem.csiro.au/my" elementFormDefault="qualified"
> attributeFormDefault="unqualified">
>   <!-- ==================================================================
> -->
> 
> <!--
> Start with a simple definition of "CodeType", being a string with a
> "codeSpace" attribute, 
> and an element of this type
> -->
> 
>   <complexType name="CodeType">
>     <simpleContent>
>       <extension base="string">
>         <attribute name="codeSpace" type="anyURI" use="optional"/>
>       </extension>
>     </simpleContent>
>   </complexType>
>   <!-- ==================================================================
> -->
>   <element name="name" type="my:CodeType"/>
> 
> <!--
> Then generate specific codelists by restricting the value of the string to
> enumerations, and fix the value of the codeSpace:
> -->
> 
>   <complexType name="ISOCountry2CharType">
>     <simpleContent>
>       <restriction base="my:CodeType">
>         <enumeration value="AF"/>
>         <enumeration value="AL"/>
>         <enumeration value="AU"/>
>         <enumeration value="ZW"/>
>         <attribute name="codeSpace"
>
fixed="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-li
> sts/list-en1-semic.txt" use="optional"/>
>       </restriction>
>     </simpleContent>
>   </complexType>
>   <!-- ==================================================================
> -->
>   <complexType name="ISOCountry3CharType">
>     <simpleContent>
>       <restriction base="my:CodeType">
>         <enumeration value="AFG"/>
>         <enumeration value="ALB"/>
>         <enumeration value="AUS"/>
>         <enumeration value="ZWE"/>
>         <attribute name="codeSpace"
> fixed="http://unstats.un.org/unsd/methods/m49/m49alpha.htm"
> use="optional"/>
>       </restriction>
>     </simpleContent>
>   </complexType>
>   <!-- ==================================================================
> -->
>   <complexType name="UNCountryType">
>     <simpleContent>
>       <restriction base="my:CodeType">
>         <enumeration value="Afghanistan"/>
>         <enumeration value="Albania"/>
>         <enumeration value="Australia"/>
>         <enumeration value="Zimbabwe"/>
>         <attribute name="codeSpace"
> fixed="http://unstats.un.org/unsd/methods/m49/m49alpha.htm"
> use="optional"/>
>       </restriction>
>     </simpleContent>
>   </complexType>
>   <!-- ==================================================================
> -->
> </schema>
> ================
> 
> 
> Microsoft's online .NET validator
> http://www.gotdotnet.com/services/xsdvalidator/Default.aspx says the
> attribute restrictions are invalid.  Why?? How can I fix it?
> 
> 
> OTOH XML Spy says "ok" but when I give it the one-element document
> 
> ============
> <?xml version="1.0" encoding="UTF-8"?>
> <my:name xmlns:my="http://xmml.ned.dem.csiro.au/my"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://xmml.ned.dem.csiro.au/my
> ./stringRestriction.xsd">2001 Survey 1</my:name>
> ============
> 
> it complains that 'Value does not match facet enumeration "AF AL AU ZW AFG
> ALB AUS ZWE Afghanistan Albania Australia Zimbabwe"'  
> Looks like a wierd bug in Spy??
> 
> 
> _____
> [This mail represents part of a discussion of work in progress 
> and should not be used for any purpose without my permission.] 
> _____
> Simon.Cox@csiro.au  CSIRO Exploration & Mining
> 26 Dick Perry Avenue, Kensington WA 6151
> PO Box 1130, Bentley WA 6102  AUSTRALIA
> T: +61 (8) 6436 8639  F: +61 (8) 6436 8555  C: +61 (4) 0330 2672
> http://www.csiro.au/page.asp?type=resume&id=CoxSimon
>  
> 
Received on Wednesday, 16 October 2002 05:36:47 GMT

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