Optional fields using xs:nillablea and xsi:nil

I would like to propose an enhancement to xforms to allow for optional field
values, for example having the ability to have a date value which is 
optional.

An optional date field would be described in XML Schema by using the 
"nillable"
schema property as follows:

<xs:element name="date" nillable="true" type="xs:date"/>

This would be edited in xforms with a input control as follows:

<xfm:input ref="date"/>

This could be rendered as described in "8.1.2 The input Element" by an
appropriately formatted text field, to allow the user to type the date, 
with a
popup calendar to aid the selection.

I would like the user to be able to unset the date field by removing all the
text from the control. This would then remove all the children nodes 
from the
date element in the instance data and set the xsi:nil attribute to true.

I propose changing section "10.1.9 The setvalue Element" to allow for 
this, by
changing the "Element nodes" bullet point from:

    "All strings are inserted into the instance data as follows:"

    "If the element has any child text nodes, the first text node is 
replaced with
    one corresponding to the new value. If no child text nodes are 
present, a text
    node is created, corresponding to the new value, and appended as the 
first child
    node."

to:

    "All strings are inserted into the instance data as follows:"

    "If the element has the schema property "nillable" set to true and 
the new value
    is the empty string (""):

        all child nodes are removed and the attribute "xsi:nil" is set 
to "true".
  
    Otherwise
         If the element has any child text nodes, the first text node is 
replaced
         with one corresponding to the new value. If no child text nodes are
         present, a text node is created, corresponding to the new 
value, and
         appended as the first child node. (as previously)
  
         If the element has the schema property "nillable" set to true 
then the
            attribute "xsi:nil" is set to "false"
    "

Received on Wednesday, 21 July 2004 10:57:15 UTC