This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 2219 - R-227: identity constraints and xsi:nil
Summary: R-227: identity constraints and xsi:nil
Status: CLOSED FIXED
Alias: None
Product: XML Schema
Classification: Unclassified
Component: Structures: XSD Part 1 (show other bugs)
Version: unspecified
Hardware: All All
: P4 normal
Target Milestone: ---
Assignee: C. M. Sperberg-McQueen
QA Contact: XML Schema comments list
URL:
Whiteboard: medium, hard, idc cluster
Keywords: resolved
Depends on:
Blocks:
 
Reported: 2005-09-14 19:20 UTC by Sandy Gao
Modified: 2007-04-27 15:36 UTC (History)
0 users

See Also:


Attachments

Description Sandy Gao 2005-09-14 19:20:05 UTC
If an element selected by the field of an identity constraint has 
xsi:nil='true', is the value treated as missing? For example, is the following 
instance valid, given the schema. 

schema
------
<xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
         <xsd:element name="root">
                 <xsd:complexType>
                         <xsd:sequence>
                                 <xsd:element ref="uid" maxOccurs="unbounded"/>
                         </xsd:sequence>
                 </xsd:complexType>
                 <xsd:unique id="foo123" name="uuid">
                         <xsd:selector xpath=".//uid"/>
                         <xsd:field xpath="."/>
                 </xsd:unique>
         </xsd:element>
         <xsd:element name="uid" nillable="true" type="xsd:anySimpleType"/>
</xsd:schema>

instance
--------
<xml version="1.0"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xsi:noNamespaceSchemaLocation="idF018.xsd">
         <uid xsi:nil="true" xsi:type="xsd:string"/>
         <uid xsi:nil="true"/>
</root>

I think this should be valid since the xsi:nil attribute on the uid elements 
would be equivalent to the elements missing for the purposes of identity 
constraints. Either way 3.11.4 of Schema part 1 could use some clarification 
around xsi:nil. 

See:
http://lists.w3.org/Archives/Public/www-xml-schema-comments/2003JulSep/0024.html
Comment 1 Sandy Gao 2007-03-28 18:44:06 UTC
The WG discussed this at a face to face meeting on 28 March and
decided to close it as FIXED.  The necessary changes were adopted in a previous
WG meeting.

Briefly, when xsi:nil=true, it's treated as if the value is missing. So the attached example will be accepted by schema 1.1.

Note that if <key> is used in place of <unique>, the xml document becomes invalid, because <key> requires that all fields are present and have values.
Comment 2 Sandy Gao 2007-04-16 13:28:30 UTC
Closing it on behave of the originator, who indicated that "The resolution seems fine and so the bug can be closed."
Comment 3 Sandy Gao 2007-04-27 15:36:11 UTC
Reply from the originator:
http://lists.w3.org/Archives/Public/www-xml-schema-comments/2007AprJun/0044.html