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

XForms: Bind value of attribute?

From: Abishek Bellamkonda <abi.bellamkonda@roadhouse.com.au>
Date: Tue, 3 Oct 2006 15:25:23 +1000
Message-ID: <235B5412B02A384F884284379E2B84F222CAFB@rh-hq.hq.roadhouseinteractive.com.au>
To: <www-forms@w3.org>

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 07:57:29 GMT

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