- From: Pete Cordell <petexmldev@codalogic.com>
- Date: Thu, 23 Aug 2012 22:46:30 +0100
- To: "Costello, Roger L." <costello@mitre.org>, <xmlschema-dev@w3.org>
It's always seemed a shame to me that <Title></Title> and <Title/> are semantically equivalent. In this case it would be handy if <Title></Title> meant the empty string and <Title/> meant the default. But it's history that that ship has sailed through the water under the bridge! Pete Cordell Codalogic Ltd Twitter: http://twitter.com/petecordell Interface XML to C++ the easy way using C++ XML data binding to convert XSD schemas to C++ classes. Visit http://codalogic.com/lmx/ or http://www.xml2cpp.com for more info ----- Original Message ----- From: "Costello, Roger L." <costello@mitre.org> To: <xmlschema-dev@w3.org> Sent: Thursday, August 23, 2012 8:04 PM Subject: Sometimes an empty value means "use the default value" and sometimes it doesn't ... right? Hi Folks, Here is a schema that has an Altitude element with a default value of 100, and a Title element with a default value of "Hello World" <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Tests"> <xs:complexType> <xs:sequence> <xs:element name="Test1"> <xs:complexType> <xs:sequence> <xs:element name="Altitude" type="xs:integer" default="100" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="Test2"> <xs:complexType> <xs:sequence> <xs:element name="Title" type="xs:string" default="Hello World" /> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> Here is an instance document that has an empty value for both Altitude and Title <?xml version="1.0" encoding="UTF-8"?> <Tests> <Test1> <Altitude></Altitude> </Test1> <Test2> <Title></Title> </Test2> </Tests> Since the empty value is not a valid integer, the Altitude element must assume the default value, 100. Since the empty value is a valid string, the Title element does not assume the default value; its value is the empty string. Thus sometimes an empty value means "use the default value" and sometimes it doesn't. Right? /Roger
Received on Thursday, 23 August 2012 21:47:05 UTC