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

Re: how to constraint sinmpleTypes

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 31 Jan 2001 16:57:08 +0000
To: Ayalew Kassahun <A.Kassahun@InfoRay.NL>
Cc: xmlschema-dev@w3.org
Message-ID: <f5b1ytjhd7f.fsf@cogsci.ed.ac.uk>
Ayalew Kassahun <A.Kassahun@InfoRay.NL> writes:

> Hi List:
> I have (what seams to me) a simple question but I difficulty expressing it
> in my schema. I want to constraint users of my schema to use only a subset
> of the simpleTypes: xsd:int, xsd:double and xsd:string. How can I specify
> that in my schema?
> For example in the following document I want the element <age
> type="xsd:short">23</age> be reported as 'invalid' because its content is of
> type short.
> <?xml version="1.0"?>
> <purchaseOrder orderDate="1999-10-20">
>     <shipTo country="US">
>         <name>Alice Smith</name>
>         <age type="xsd:short">23</age>
>         <city>Mill Valley</city>
>         <state>CA</state>
>         <zip>90952</zip>
>     </shipTo>
>     <billTo country="US">
>         <name>Robert Smith</name>
>         <street>8 Oak Avenue</street>
>         <city>Old Town</city>
>         <state>PA</state>
>         <zip>95819</zip>
>     </billTo>
> </purchaseOrder>

I'm not sure I understand either the question or the motivation, but
I'll try to help.

I'm assuming that _you're_ assuming that there's a schema which
provides a type for <age> of xs:integer.  If you add
block='restriction' to the element declaration for <age>, that
effectively bars users from using xsi:type on <age> in instances.

But why do you care?  All shorts are ints, by definition.

  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 Wednesday, 31 January 2001 11:57:12 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:49 UTC