W3C home > Mailing lists > Public > www-forms@w3.org > February 2006

absent vs empty attributes

From: Duane Gran <dgran@duanegran.com>
Date: Wed, 1 Feb 2006 09:03:58 -0500
Message-Id: <BD7F9719-85EE-43FA-89CC-88E71856D22A@duanegran.com>
To: www-forms@w3.org

I have a question about attributes which have required values, but  
the attribute itself is optional.  I'm attempting to bind an XForm  
checkbox to an attribute, called keyDate, which is defined in the  
following Schema:

<xsd:attribute name="keyDate" use="optional">
   <xsd:simpleType>
     <xsd:restriction base="xsd:string">
       <xsd:enumeration value="yes"/>
     </xsd:restriction>
   </xsd:simpleType>
</xsd:attribute>

So the only valid instance document would be one where the keyDate  
attribute is absent, or one where it is present and contains "yes" as  
the value.  My preferred behavior for this would be the production of  
an instance document without the attribute when the box is unchecked,  
but if checked the attribute's value would be set.  Is this  
possible?  Have others come up with solutions for this scenario?

If it helps, below is my XForms control, as it is used in OPS:

                   <xforms:select ref="@keyDate" appearance="full">
                     <xforms:label class="fixed-width  
attribute">keyDate: </xforms:label>
                     <xforms:item>
                       <xforms:label>yes</xforms:label>
                       <xforms:value>yes</xforms:value>
                     </xforms:item>
                   </xforms:select>

Duane Gran
Received on Wednesday, 1 February 2006 22:56:15 GMT

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