Simple question on elements constraints

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>
...

but the problem is that the value of the element for the post validation is
in the case of an empty element the value specified by the 'fixed' or
'default' attributes. In this case the value is 3000 and its length is
grather than 1 character as specified in the 'noEmptyElement' type
restrictions.
Is there an constraint attribute on the 'element' element specifying that
the content of such an element cannot be empty?

Adalbert



Adalbert Wysocki, software engineer
<mailto:awysocki@imediation.com>
phone: +33 (0)1 71.00.68.67 
fax: +33 (0)1 71.00.68.02

Received on Tuesday, 23 January 2001 13:55:37 UTC