W3C home > Mailing lists > Public > xmlschema-dev@w3.org > July 2012

Re: What's the difference between equality and identity?

From: Michael Kay <mike@saxonica.com>
Date: Wed, 18 Jul 2012 13:58:19 +0100
Message-ID: <5006B2EB.1050403@saxonica.com>
To: xmlschema-dev@w3.org

On 18/07/2012 13:30, Costello, Roger L. wrote:
> Hi Folks,
>
> In section "3.2.1 The Attribute Declaration Schema Component" of the structures specification it discusses attribute default and fixed values.
>
> It contains this sentence:
>
>      Note that it is values that are checked, not strings,
>      and that the test is for either equality or identity.
>
> What is a test for "identity?"
The distinction is explained here: 
http://www.w3.org/TR/xmlschema11-2/#value-space

For example:

* positive and negative zero are equal but not identical.

* NaN is identical to itself but not equal to itself.

In XSD (unlike XPath) a value is never equal (nor identical) to a value 
of a different primitive type - so an integer can never equal a double.

There are in fact very few cases where equality tests and identity tests 
give different results. At one time there were more. For example, the 
xs:time values 00:00:00 and 24:00:00 are both equal and identical (IIRC, 
at one stage during development, they were equal but not identical). 
Similarly the durations P1Y and P12M are both equal and identical.

Michael Kay
Saxonica
Received on Wednesday, 18 July 2012 12:58:46 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 18 July 2012 12:58:46 GMT