This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 6249 - exclusions for simple type
Summary: exclusions for simple type
Status: NEW
Alias: None
Product: XML Schema
Classification: Unclassified
Component: Datatypes: XSD Part 2 (show other bugs)
Version: Future
Hardware: All Windows 3.1
: P2 enhancement
Target Milestone: ---
Assignee: David Ezell
QA Contact: XML Schema comments list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-27 12:05 UTC by Sjoerd van Hagen
Modified: 2012-12-04 00:52 UTC (History)
1 user (show)

See Also:


Attachments

Description Sjoerd van Hagen 2008-11-27 12:05:38 UTC
I would like to have a feature added to the XML schema specification. It is quite simple to understand and implement and adds considerable power to schema as a validation tool.

I propose to add the element exclude to the restriction that can be used in simple types. This can be very useful to model identifiers, where you want to exclude reserved words but cannot enumerate all possibilities you do want to allow.

Say you would like to have identifiers consisting of upper and lowercase characters and digits, which have to start with a character and 'int', 'double' and 'string' are forbidden it would look like this:

<xs:simpleType name="identifier" xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:restriction base="xs:string">
		<xs:pattern value="[A-Za-z][A-Za-z0-9]*"/>
		<xs:minLength value="1"/>
		<xs:maxLength value="32"/>
		<xs:exclude value="int"/>
		<xs:exclude value="double"/>
		<xs:exclude value="string"/>
	</xs:restriction>		
</xs:simpleType>

At this moment there is no way to do this in schema and even with extended regular expression power it would be a pain while it can be very useful in many cases.
Comment 1 Michael Kay 2008-11-27 12:16:26 UTC
Assertions in XSD 1.1 provide a way to do this:

<xs:assert test="not(. = ('int', 'double', 'string'))"/>

Michael Kay
(personal response)