- From: John Boyer <boyerj@ca.ibm.com>
- Date: Fri, 18 Jun 2010 07:18:37 -0700
- To: "Leigh L. Klotz, Jr." <Leigh.Klotz@Xerox.com>
- Cc: public-forms@w3.org
- Message-ID: <OFB1640BA1.DD0E2FC0-ON88257746.004C6EED-88257746.004E9BCF@ca.ibm.com>
Hi Leigh,
First, to clarify, you're trying to get the value attr in setvalue to
evaluate "name" as the name of the hotel that is both good and cheap, i.e.
the value expression evaluates relative to the repeat item node rather
than the result of the ref in setvalue.
While the ref sets the starting node of the value, the repeat item node
happens to be the "inscope evaluation context node" of the setvalue
action, which sets the starting node of the ref.
Therefore, no, the context attribute will not help you with resetting the
evaluation node for the value attr. The context attribute allows override
of the inscope evaluation context of the element containing the context
attribute, so it would only help you to set a context for the ref of the
setvalue.
Unfortunately, Mark's blog post is also incorrect, and you are correct,
that using the current() function does not work. Later in Mark's post, he
does acknowledge that.
The actual fix to the problem is the context() function [1], and you're
hitting on the exact reason it was added.
[1] http://www.w3.org/TR/xforms11/#fn-context
In your markup, use this:
<setvalue ev:event="DOMActivate"
ref="instance('home')/hang/your/hat" value="context()/name" />
If Mark's post contained context() where it currently contains current(),
then his blog post would work without having to resort to the index()
function:
<xf:setvalue bind="testBind" value="context()/VO_ID" />
Finally, note that context() is one of the harder functions to implement,
so you may have to file an issue with your flavourite XForms implementer
if the above doesn't work. And meanwhile, could you explain further what
breaks when you use the alternative method of the index() function to
solve this problem in an inner repeat? Offhand, the only reason I can
think of why it wouldn't work is that the harder part of implementing the
index() function has not been done properly, which would mean another
issue for your flavourite XForms implementer.
Cheers,
John M. Boyer, Ph.D.
IBM Distinguished Engineer, Interactive Web Applications and Documents
IBM Lotus Forms Architect
Workplace, Portal and Collaboration Software
IBM Canada Software Lab, Victoria
E-Mail: boyerj@ca.ibm.com
Blog: http://www.ibm.com/developerworks/blogs/page/JohnBoyer
Blog RSS feed:
http://www.ibm.com/developerworks/blogs/rss/JohnBoyer?flavor=rssdw
From:
"Leigh L. Klotz, Jr." <Leigh.Klotz@Xerox.com>
To:
public-forms@w3.org
Date:
06/17/2010 11:37 PM
Subject:
@context everywhere; applies to ref and value separately, or applies
before ref, then ref applies to value?
When we add @context to actions [1], would this work to deal with the
lost repeat context in setvalue problem?
<repeat nodeset="instance('directory')/hotels/hotel[@good='yes' and
@cheap='yes']">
<trigger>
<label>Book <output ref="name" /></label>
<setvalue ev:event="DOMActivate" context="."
ref="instance('home')/hang/your/hat" value="name" />
</trigger>
</repeat>
(You can work around this loss of context with index(), but not in the
case of nested repeats.)
Interestingly, Mark Birbeck suggests [2] that current() solves this
problem, but my understanding was that
<setvalue ref="instance('home')/hang/your/hat" value="current()/name" />
was the same as
<setvalue ref="instance('home')/hang/your/hat" value="./name" />
and current() would be useful only inside predicates.
Am I wrong on this count?
[1] http://www.w3.org/MarkUp/Forms/wiki/@context_everywhere
[2] http://www.formsplayer.com/node/200
Leigh.
Received on Friday, 18 June 2010 14:19:11 UTC