RE: @context everywhere; applies to ref and value separately, or applies before ref, then ref applies to value?

Hi Leigh,

Every element has an in-scope evaluation context, including those child 
elements you talked about [1].  See especially the text after the list, 
which indicate that elements that are not binding elements have an 
in-scope evaluation context equivalent to what they would have if they 
were binding elements.

[1] http://www.w3.org/TR/xforms11/#expr-eval

So, yes you actually should be able to use context() in 
output/mediatype/@value.

Although context() is the "right" answer, can you still let me know 
whether or not you see a specific problem with using index() in that case 
you raised earlier, when further amended to be an inner repeat?  I'd like 
to assume it is actually not a problem unless you say otherwise.

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:
"Klotz, Leigh" <Leigh.Klotz@xerox.com>
To:
John Boyer/CanWest/IBM@IBMCA
Cc:
<public-forms@w3.org>
Date:
06/18/2010 11:24 AM
Subject:
RE: @context everywhere; applies to ref and value separately, or applies 
before ref, then ref applies to value?



Thank you, John.  That's great news.  I had gotten confused and thought 
context was an XForms 1.2 feature; so @context everywhere is, but 
context() isn't.
I'll note this in the wikipage on @context everywhere.
 
I have another question about context(), though, and it would have applied 
equally to my misunderstood @context:
 
#fn-context says that it applies to "context node of the nearest ancestor 
element".  So, that means it isn't useful for child elemements which allow 
evaluation of xpath expressions for what would otherwise be static 
attribute values.
For example, output/mediatype/@value cannot use context().
 
Leigh.
 
 

From: John Boyer [mailto:boyerj@ca.ibm.com] 
Sent: Friday, June 18, 2010 7:19 AM
To: Klotz, Leigh
Cc: public-forms@w3.org
Subject: Re: @context everywhere; applies to ref and value separately, or 
applies before ref, then ref applies to value?


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 18:49:43 UTC