W3C home > Mailing lists > Public > www-forms@w3.org > October 2007

Re: Hide items from list

From: Frederik Elwert <felwert@uni-bremen.de>
Date: Thu, 25 Oct 2007 19:05:34 +0000
To: www-forms@w3.org
Message-Id: <1193339134.6990.113.camel@FredDesk>

Hi John,

thanks for your suggestion! I think that understand the way you propose
and it seems to be a clean XForms solution for the problem.

But since I rely on my own implementation of (a subset of) XForms
processing, it makes things much harder to implement and the actual file
structure much more complicated.
On the other hand, doing all by myself gives me the opportunity to add
features that I need. So it's a bit a XForms compliance versus
pragmatical considerations.

So for this I think I'll just implement a relevant attribute for
xf:items in my own namespace and use it directly. Since there is not
much actual information lost for other XForms clients, I think it might
be the better way to go.

Thanks,
Frederik

Am Donnerstag, den 25.10.2007, 10:05 -0700 schrieb John Boyer:
> 
> Hi Frederik, 
> 
> One easy way is to apply your own notion of relevant to your own data
> using the calculate MIP. 
> 
> Suppose you organize your data thus: 
> 
> <instance id="data"> 
> <questions xmlns=""> 
>    <question><prompt>X?</prompt><answer>A</answer></question> 
>    <question><prompt>Y?</prompt><answer>C</answer></question> 
>    <question><prompt>Z?</prompt><answer>B</answer></question> 
> </questions> 
> </instance> 
> 
> <instance id="list"> 
>     <entries> 
>         <entry relevant="true" value="A">Choice 1</entry> 
>         <entry relevant="true" value="B">Choice 2</entry> 
>         <entry relevant="false" value="C">Choice 3</entry> 
>    </entries> 
> </instance> 
> 
> Then you can create a bind that decides how to set the relevant
> attributes of all the entries or of a particular entry, like this: 
> 
> <bind nodeset="instance('list')/entry[3]/@relevant"
> calculate="choose(instance('data')/Y/answer = 'B', 'true',
> 'false')"/> 
> 
> This makes the third entry of the list have an attribute value that is
> based on how question Y was answered.   
> Now suppose the list is used to help drive the answer to question Z. 
> 
> You can then leverage your attribute in the itemset's nodeset
> selector, like this: 
> 
> <select1 ref="question[3]/answer"> 
>    <label ref="../prompt"/> 
>    <itemset nodeset="instance('list')/entry[@relevant='true']"> 
>       <label ref="."/> 
>       <value ref="@value"/> 
>    </itemset> 
> </select1> 
> 
> As a final note, please understand that this would be your own
> *notion* of relevant, not to be confused with the relevant model item
> property.  I could have just as easily called it "visible" or "show"
> because it's just an attribute name that helps to show or hide certain
> itemset items based on conditions in the data. 
> 
> Hope this helps. 
> 
> John M. Boyer, Ph.D.
> STSM: Lotus Forms Architect and Researcher
> Chair, W3C Forms Working Group
> Workplace, Portal and Collaboration Software
> IBM Victoria Software Lab
> E-Mail: boyerj@ca.ibm.com  
> 
> Blog: http://www.ibm.com/developerworks/blogs/page/JohnBoyer
> 
> 
> 
> 
> Frederik Elwert
> <felwert@uni-bremen.de> 
> Sent by: www-forms-request@w3.org 
> 
> 10/25/2007 09:28 AM 
> 
> 
>                To
> www-forms@w3.org 
>                cc
> 
>           Subject
> Hide items from
> list
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Hello!
> 
> In a survey application based on XForms, I want to implement filtering
> of pages, questions and question items. For pages (which are just
> xf:groups) and questions (which are form controls), this is easily
> possible with @relevant.
> 
> But how can I filter, i.e. hide, xf:items from xf:select and
> xf:select1
> controls?
> 
> E.g., there is one question (xf:select1), "Do you have a dog?" with
> yes
> or no as possible anwers. Now, there's another question (xf:select)
> "What do you do in your leisure time?" with "reading", "swimming" and
> "play with my dog" as possible answers. Now I would of course want the
> last answer only to be visible when the answer to the first question
> is
> "yes".
> 
> Any help is appreciated.
> 
> Regards,
> Frederik
> 
> 
Received on Thursday, 25 October 2007 19:05:50 GMT

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