- From: Andrew Layman <andrewl@microsoft.com>
- Date: Thu, 4 Jan 2001 14:04:23 -0800
- To: "'www-xml-schema-comments@w3.org'" <www-xml-schema-comments@w3.org>
David Beech recently posted a message[1] citing the xsi:null feature in XML Schemas and commenting on some uses of this in relation to the NULL feature of typical relational databases. I would like to point out some of the significance of David's commendably careful wording. David writes "If the element is omitted, it is 'not providing' any information (e.g. that column value was not extracted from the database row)." This leaves open several possibilities regarding why it was not extracted. One may be that it was never requested. Another is that the column is not present in that row. Another is that the column is present and had a "value" of NULL. Another is that the column is present in the database but the value of the column matches a default value supplied in the schema. Since the XSD specification describes syntactic and type constraints, not database mappings, all these and causes others are possible. (However, the use of the definite article "the" suggests that all data originates in and is understood by reference to a database. That assumption is beyond the scope of the schemas design.) David also carefully uses "e.g." when he writes "If the element is present with xsi:null="true", it is 'providing a value' of the null attribute as 'anti' normal element content (e.g. that column value extracted from the database row had a null value instead of a value of the specified type)." Indeed, this is one possible use of xsi:null. The normative portion of the specification says the following: If {nullable} is true, then an element may also be valid if it carries the namespace qualified attribute with [local name] null from namespace http://www.w3.org/2000/10/XMLSchema-instance and value true (see xsi:null (§2.6.2)) even if it has no text or element content despite a {content type} which would otherwise require content. Formal details of element validation are described in Element Locally Valid (Element) (§3.3). That is, the effect of xsi:null, as described by the XML Schemas specification, is simply to signal that an instance element is valid when empty even though the validating schema definition of the element's type has a non-empty content model. The mapping of NULLs in relational databases to something specific in relational databases is not part of the XML schemas specification. An element with a xsi:null='true' attribute may correspond to a column in a database table containing a NULL, but it might correspond to something else entirely, or to nothing at all, and a NULL in a database column might correspond to an omitted element, an element marked xsi:null='true' or to something else entirely. The specification allows all of these. [1] http://lists.w3.org/Archives/Public/www-xml-schema-comments/2001JanMar/0022. html
Received on Thursday, 4 January 2001 17:05:26 UTC