W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > October to December 2004

Identity versus Equality in enumerations and fixed value constraints

From: Mary Holstege <mary.holstege@marklogic.com>
Date: Fri, 03 Dec 2004 09:51:44 -0800
To: www-xml-schema-comments@w3.org
Cc: holstege@mathling.com
Message-ID: <opsif08iadfi7tae@mail.cerisent.com>

In the call today we decided to use identity for value constraints, just  
as we
do for enumeration, on the logic that a fixed value constraint is like an
enumeration with a single value.

Noah and I expressed a certain discomfort with identity in both these  
especially with respect to precision decimal.

    <xs:simpleType name="u2numbers">
      <xs:restriction base="xs:precisionDecimal">
         <xs:enumeration value="1.0"/>
         <xs:enumeration value="2.0"/>
         <xs:enumeration value="3.0"/>
         <xs:enumeration value="14.0"/>

We accepted that "1" and "1.00" would not be valid against this  
enumeration on
the grounds that enumerations of decimals were not used in practice, so  
infelicity was unlikely to bite anyone.

The work-around would be to enumerate a sufficient range of precisions to  
the most likely cases to turn up in practice:
    <xs:simpleType name="u2numbers">
      <xs:restriction base="xs:precisionDecimal">
         <xs:enumeration value="1"/>
         <xs:enumeration value="1.0"/>
         <xs:enumeration value="1.00"/>
         <xs:enumeration value="2"/>
         <xs:enumeration value="2.0"/>
         <xs:enumeration value="2.00"/>
         <xs:enumeration value="3"/>
         <xs:enumeration value="3.0"/>
         <xs:enumeration value="3.00"/>
         <xs:enumeration value="14"/>
         <xs:enumeration value="14.0"/>
         <xs:enumeration value="14.00"/>
Painful in practice, impossible in the general case (although I suppose you
could enumerate to the limits of precision supported by your processor,  

Or you put in a pattern facet instead, which can also be painful.

Consider this definition:

<xs:element name="meterMin" type="xs:precisionDecimal"/>

Somewhere in a content model:
    <xs:element ref="meterMin" fixed="1.0"/>

In this case <meterMin>1.00</meterMin>  and <meterMin>1</meterMin>
would be rejected.

Here, however, there is no workaround that allows you the simplicity of  
the fixed attribute: you have to change the type. If you wanted to have
different fixed values for different uses of the element meterMin in your
schema, you have to jump through some rather painful hoops using local
definitions that have nasty enumerations or patterns in them: the type of
each use of meterMin would have to be different.

I still question the wisdom of using identity in either of these cases.  
types do not distinguish identity and equality, and in those cases that  
do, the
results are unhelpful, as shown.

Received on Friday, 3 December 2004 17:53:16 UTC

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