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

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 UTC