Re: Simple question on elements constraints

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 UTC