W3C home > Mailing lists > Public > www-forms@w3.org > April 2005

Re: WXS types in XForms

From: Victor Engmark <victor.engmark@cern.ch>
Date: Fri, 08 Apr 2005 14:01:24 +0200
Message-ID: <42567294.3010507@cern.ch>
To: Mark Birbeck <mark.birbeck@x-port.net>
CC: www-forms@w3.org

Mark Birbeck wrote:

>Victor,
>  
>
>>I believe the problem arises from null (the empty string) not 
>>being a valid number. The same goes for dates, and I've used 
>>the following solution:
>>  <simpleType name="null_date">
>>    <union>
>>      <simpleType>
>>        <restriction base="date">
>>        </restriction>
>>      </simpleType>
>>      <simpleType>
>>        <annotation>
>>          <documentation>The empty string</documentation>
>>        </annotation>
>>        <restriction base="string">
>>          <length value="0"/>
>>        </restriction>
>>      </simpleType>
>>    </union>
>>  </simpleType>
>>    
>>
>
>You're right in describing the problem, but XML Schema provides a better
>solution that saves you having to create lots of new data types with unions
>in -- it's the concept of 'nillable'. This allows an element that is empty
>to be classed as valid, even if its schema type does not allow this.
>
>To indicate that your element can be set to nil, you use xsd:nillable [1] in
>the schema definition. Note however that this is an attribute of
>xsd:element, not the type, so Alexander's example would need to become:
>
>  <xsd:element name="some-elem" type="myType" nillable="true" />
>
>  <xsd:simpleType name="myType">
>    <xsd:restriction base="xsd:decimal">
>      <xsd:minInclusive value="0" />
>      <xsd:fractionDigits value="5" />
>    </xsd:restriction>
>  </xsd:simpleType>
>
>Although this might seem inconvenient, it is more logical. If you take your
>example, you have effectively invented a new data type that is an amalgam of
>a date and nothing. My guess is that this doesn't really reflect your data
>structure. What you most likely have is an *element* that can either take a
>date, or be left empty. The XML Schema syntax reflects this. (It also allows
>you to use other people's data types without having to create new types all
>the time.)
>
>Once you have the schema set up, then to make use of it you use @xsi:nil [2]
>on your element:
>
>  <some-elem xsi:nil="true" />
>  
>
While this is a neat feature, I really don't understand why I should 
have to include 'xsi:nil="true"' to use it. It's already obvious that 
the element is empty. In addition, I don't want any extra logic to 
handle the paradox of having nil=true /and/ element contents.

Can this attribute be avoided? <flame>If not, I'll rather go with the 
/logical/ solution.</flame>

-- 
Victor Engmark
"Quid quid latine dictum sit, altum viditar" - "What is said in latin, 
sounds profound"
Received on Friday, 8 April 2005 12:01:28 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 10 March 2012 06:22:00 GMT