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

Re: absent vs empty attributes

From: Duane Gran <dgran@duanegran.com>
Date: Thu, 2 Feb 2006 13:02:50 -0500
Message-Id: <ACF49084-0A91-4A89-A41A-2B47992ED4DE@duanegran.com>
Cc: Florian Lacoste <florian.lacoste@evidian.com>
To: www-forms@w3.org

Florian,

Thank you for the explanation below.  I imagined a scenario similar  
to this, but possibly others have different ways of implementing it.   
Is this an issue this is being considered by the working group?

Duane

On Feb 2, 2006, at 5:24 AM, Florian Lacoste wrote:

>
> - wrote:
>> 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>
>
> Hi,
>
> I tried to do something like that once. The solution I found was a  
> little complicated for what it did but anyway:
>
> Define a "flag" attribute in another instance or in a non submitted  
> part of your instance. Its value is true(). Then define the  
> relevant attribute for keyDate: relevant=". = 'yes' or /path_to_flag"
>
> Then add an event switching the flag value to false() on submit and  
> another switching its value to true() on submit-error.
>
> The flag being always true when you display the form, your keyDate  
> will show and as it switches to false on submitting the data, it  
> will be submitted only if its value is "yes". In case of a submit  
> error, it goes back to true, thus keyDate is still displayed.
>
> I did that when I was just a beginner in XForms, it worked. There  
> is surely a better way but I never thought about it since.
>
> Hope that helps. Regards,
>
> -- 
> Florian
>
Received on Thursday, 2 February 2006 18:02:59 GMT

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