- From: John Boyer <boyerj@ca.ibm.com>
- Date: Thu, 25 Oct 2007 10:05:36 -0700
- To: Frederik Elwert <felwert@uni-bremen.de>
- Cc: www-forms@w3.org, www-forms-request@w3.org
- Message-ID: <OF915AFD2B.3AB8A8C3-ON8825737F.005C6524-8825737F.005DF2F2@ca.ibm.com>
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 17:06:31 UTC