W3C home > Mailing lists > Public > xmlschema-dev@w3.org > May 2003

Re: Meaning of xs:pattern in xs:boolean

From: Jeni Tennison <jeni@jenitennison.com>
Date: Fri, 30 May 2003 09:33:33 +0100
Message-ID: <3662808227.20030530093333@jenitennison.com>
To: "Wiedmann, Jochen" <jochen.wiedmann@softwareag.com>
CC: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>

Hi Jochen,

> I see that the boolean type is constrained by xs:pattern. As there
> are only four possible values, I have the impression that patterns
> do not make much sense for booleans, unless the meaning is: "true",
> if the pattern matches, and "false" otherwise. Is that the case?

The pattern facet constrains the lexical representation of the data
type within an XML document. An example with xs:boolean would be to
create a data type that could only use the lexical values "true" and
"false" and not the lexical values "1" and "0":

<xs:simpleType name="true-or-false">
  <xs:restriction base="xs:boolean">
    <xs:pattern value="true" />
    <xs:pattern value="false" />

If the <foo> element were declared as being of type true-or-false then
the following would be valid:


while the following would be invalid:


Likewise, you could restrict xs:boolean to only allow the lexical
representations "1" and "0" or, if you were feeling particularly
contrary, "true" and "0" or "1" and "false".

(In contrast, the enumeration facet wouldn't make any sense on
xs:boolean because all you could say is "this boolean must have the
value true" or "this boolean must have the value false", and if you
want to do that you should probably fix the value of the
attribute/element instead. That's why the enumeration facet isn't
allowed with xs:boolean.)



Jeni Tennison
Received on Friday, 30 May 2003 04:33:46 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:02 UTC