W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > July to September 2002

Nillable seems inconsistent

From: by way of <mark_buchner@standardlife.com>
Date: Wed, 10 Jul 2002 17:10:48 -0600
Message-Id: <5.1.0.14.1.20020710171043.028202f8@localhost>
To: W3C XML Schema Comments list <www-xml-schema-comments@w3.org>




I have two nillable Elements.  One validates when the tag is empty, the
other does not.  The tag that does not valid is *effectively* the same as
the validating one, i.e. a string, albeit with some associated restriction.

My question is: why don't BOTH tags fail validation when they are empty ?

Any distinction between the tags must be arbitrarily obtuse (they are in
effect simple strings)...or have I missed something ?

Please help clarify my understanding.

Many thanks

Mark Buchner


Example:

XSD
<xsd:element name="Person" type="PersonType"/>
  <xsd:complexType name="PersonType">
   <xsd:sequence>
    <xsd:element name="Name" type="xsd:string" nillable="true"/>
    <xsd:element name="DOB" type="MyDate" nillable="true"/>
   </xsd:sequence>
  </xsd:complexType>
  <xsd:simpleType name="MyDate">
   <xsd:restriction base="xsd:string">
    <xsd:length value="10"/>
    <xsd:pattern value="[0-9]{4}-[0-9]{2}-[0-9]{2}"/>
   </xsd:restriction>
  </xsd:simpleType>

XML (this validates)
<Person xmlns:xsi="..." xsi:noNamespaceSchemaLocation="myfile.xsd">
  <Name/>
  <DOB>2001-01-01</DOB>
</Person>

XML (this DOES NOT validate)
<Person xmlns:xsi="..." xsi:noNamespaceSchemaLocation="myfile.xsd">
  <Name/>
  <DOB/>
</Person>




For more information on Standard Life, visit our website
http://www.standardlife.com/

The Standard Life Assurance Company, Standard Life House, 30 Lothian Road,
Edinburgh EH1 2DH, is registered in Scotland (No. SZ4) and regulated by the
Financial Services Authority. Tel: 0131 225 2552 - calls may be recorded or
monitored. This confidential e-mail is for the addressee only. If received
in error, do not retain/copy/disclose it without our consent and please
return it to us. We virus scan and monitor all e-mails but are not
responsible for any damage caused by a virus or alteration by a third party
after it is sent. 
Received on Wednesday, 10 July 2002 19:12:24 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 6 December 2009 18:13:01 GMT