Re: XForms: Bind value of attribute?

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 UTC