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

Re: XForms: Bind value of attribute?

From: John Boyer <boyerj@ca.ibm.com>
Date: Tue, 3 Oct 2006 09:49:49 -0700
To: "Abishek Bellamkonda" <abi.bellamkonda@roadhouse.com.au>
Cc: www-forms@w3.org, www-forms-request@w3.org
Message-ID: <OF4E6398CE.ACE95536-ON882571FC.005C5DD1-882571FC.005C7499@ca.ibm.com>
Yes, you can use ref to bind a UI control to an attribute.  So instead of 
using a value element in your data, you could use a value attribute. Then, 
the refs on your select1 would say ref="@value" instead of ref="value".

Best regards,
John M. Boyer, Ph.D.
STSM: Workplace Forms Architect and Researcher
Co-Chair, W3C XForms Working Group
Workplace, Portal and Collaboration Software
IBM Victoria Software Lab
E-Mail: boyerj@ca.ibm.com  http://www.ibm.com/software/

Blog: http://www.ibm.com/developerworks/blogs/page/JohnBoyer





"Abishek Bellamkonda" <abi.bellamkonda@roadhouse.com.au> 
Sent by: www-forms-request@w3.org
10/02/2006 10:25 PM

To
<www-forms@w3.org>
cc

Subject
XForms: Bind value of attribute?







My scenario is like this, I have a model:
<data>
<Animals>
<Cat appearance="full" name="Cat 1" ><value>Red</value></Cat>
<Cat appearance="compact" name="Cat 2"><value>Green</value></Cat>
<Cat appearance="minimal" name="Cat 3"><value>Brown</value></Cat>
</Animals>
</data>


Now I want to display the cat colors like this:
I want full select1 for Cat1 (appearance = full), compact select1 for
Cat 2, and minimal select1 for Cat 3. Does xForms support like
xsl:attribute element or something? We can ref any element, but can we
do the same for attribute? I am currently doing like this, which works,
but I was wondering if there was a better way.

<xf:repeat nodeset="Animals/Cat">
<!-Show full -->
<xf:group nodeset="current()[@apprearance='full']">
<xf:select1 ref="value" appearance="full">
                 <xf:label ref="../@name"/>
<xf:itemset nodeset="/data/Colors/data">
                   <xf:label ref="."/>
                   <xf:value ref="."/>
                 </xf:itemset>
</xf:select1>
</xf:group>

<!-Show Minimal -->
<xf:group nodeset="current()[@apprearance='compact']">
<xf:select1 ref="value" appearance="compact">
                 <xf:label ref="../@name"/>
<xf:itemset nodeset="/data/Colors/data">
                   <xf:label ref="."/>
                   <xf:value ref="."/>
                 </xf:itemset>
</xf:select1>
</xf:group>

<!-Show Compact -->
<xf:group nodeset="current()[@apprearance='compact']">
<xf:select1 ref="value" appearance="compact">
                 <xf:label ref="../@name"/>
<xf:itemset nodeset="/data/Colors/data">
                   <xf:label ref="."/>
                   <xf:value ref="."/>
                 </xf:itemset>
</xf:select1>
</xf:group>

</xf:repeat>

With Regards,
Abi (Abishek Bellamkonda)
Senior Architect / Technology Specialist / Tech Lead
Roadhouse Technologies PTY. LTD.
9/663 Victoria Street
Abbotsford 3067 Australia

T+ 61 3 9427 7522
F+ 61 3 9427 7533
E abi@roadhouse.com.au
W www.roadhouse.com.au
Received on Tuesday, 3 October 2006 16:50:23 GMT

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