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

Re: Simple question on elements constraints

From: Morris Matsa <mmatsa@us.ibm.com>
Date: Wed, 24 Jan 2001 10:29:10 -0500
To: francis@redrice.com
Cc: Adalbert Wysocki <waldi@imediation.com>, xmlschema-dev@w3.org, "David E. Cleary" <davec@progress.com>
Message-ID: <OFF22F16FF.BBE91B67-ON852569DE.0053F0B2@somers.hqregion.ibm.com>

On the first point:  David Cleary had made the assumption that the desire
was for an integer which happened to be 3000.  Adalbert Wysocki will have
to tell us if this is fundamentally an integer or a string.  If it is an
integer, and David is right, then it's probably better to derive from
integer as David did so that it's obvious to all Schema tools, and then he
would have to use a pattern restriction to avoid allowing other forms of
the number 3000 (of course Adalbert will also have to tell us if he minds
those.  I made that assumption.)  If it's really a string, then I agree
that the best solution is restriction string with an enumeration as Francis
Norton did below.

On your second point:  I don't see anything at your link saying that
"fixed" and "default" apply only to attributes.  I believe that they apply
to elements as well, see [1].

[1] http://www.w3.org/TR/xmlschema-1/#Element_Declaration_details

Francis Norton <francis@redrice.com> on 01/24/2001 07:18:23 AM

Please respond to francis@redrice.com

To:   Adalbert Wysocki <waldi@imediation.com>
cc:   xmlschema-dev@w3.org
Subject:  Re: Simple question on elements constraints


I think there are two questions here. First, how to specify a fixed,
non-empty value for a mandatory element.

This can be done using an enumeration (see
http://www.w3.org/TR/xmlschema-0/#ref10), eg:

<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
  <xsd:element name="root">
        <xsd:element name="fred" type="fixedNotEmpty"/>
  <xsd:simpleType name="fixedNotEmpty">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="3000"/>

The second question has to do with defaults. "fixed" and "default" only
apply to attribute declarations (see
http://www.w3.org/TR/xmlschema-0/#ref36) and are specified via the "use"
and "value" attributes, eg you could add:

      <xsd:attribute name="weather" use="fixed" value="wet" />

after the </xsd:sequence> above, and while both XML Spy 3.5 and xsv will
allow the "weather" attribute to be absent, neither will allow it to be
empty or to have any value but "wet".

Hope this helps -

Received on Wednesday, 24 January 2001 10:31:13 UTC

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