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

Re: Simple question on elements constraints

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 23 Jan 2001 19:33:02 +0000
To: Adalbert Wysocki <waldi@imediation.com>
Cc: xmlschema-dev@w3.org
Message-ID: <f5bhf2q3vyp.fsf@cogsci.ed.ac.uk>
Adalbert Wysocki <waldi@imediation.com> writes:

> Hi all,
> I have a very simple question but it better to ask experienced people rather
> than write dirty thinks.
> The context is the validation of XML documents using XMLSchema.
> How can I specify that an element must have a fixed value and cannot have an
> empty one.
> 
> example:
> -------
> <?xml version="1.0"?>
> <contract>
>   <id></id>
> </contract>
> 
> This document is not valid because the element 'id' is empty whereas it should
> be filled with a value and this value equals for example '3000'.
> 
> I tryed following:
> .....
> <xsd:element name="id" type="noEmptyElement" fixed="3000"/>
> ....
> <xsd:simpleType name="noEmptyElement">
>   <xsd:restriction base="xsd:string">
>     <minLength value="1"/>
>   </xsd:restriction>
> </xsd:simpleType>

Just remove the fixed="3000" and you'll have what you want.

ht
-- 
  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 Tuesday, 23 January 2001 14:33:08 GMT

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