- From: Steven Pemberton <steven.pemberton@cwi.nl>
- Date: Thu, 15 Dec 2016 12:00:00 +0100
- To: XForms <public-xformsusers@w3.org>
I'm currently going through all the evaluation contexts, trying to make it simpler to describe. OVERVIEW An element inherits a context (from its ancestors). If @model references a different model to that context, the default context of @model is used instead. In the resulting context, @context is evaluated if present, to give a context. >>> That is the in-scope context. Then @ref is evaluated or @bind is used, to give what I will call the element context. (Strictly speaking, as the spec now stands, if @bind is used there is no in-scope context. However, you still need it for evaluating attributes, so I am assuming that this is an oversight, and even if you use @bind the in-scope context is as described above) Either the element context or the in-scope context is used for evaluating attributes (apart from @context). The element context is then used as inherited context for contained elements. So we have three possible contexts for evaluation of an expression: the inherited, the in-scope, and the element. (There is also a dynamic scope created for each item of a sequence binding) Here is an overview of all expression attributes, and in which context they are evaluated according to the spec: GLOBAL ATTRIBUTES @context: inherited @ref: in-scope @value: element AVT: in-scope ELEMENT ATTRIBUTES bind@relevant, required, readonly, calculate: (dynamic) element function/result/@value: element var/@value: element output/@value: element output/mediatype/@value: element select/item/@value: element select/value/@value: element select/itemset/@value: (dynamic) element select/itemset/@copy: NOT SPECIFIED itemset also uses the dynamic scope repeat/@indexref: in-scope setindex/@index: NOT SPECIFIED submission/@targetref: in-scope submission/resource/@value: element submission/method/@value: element submission/header/@value: (dynamic) element setvalue@value: element insert@at: an evaluation context where the context node is the first node of the target-sequence, the context size is the size of the target-sequence, and the context position is 1. insert@origin: in-scope delete@at: an evaluation context where the context node is the first node of the target-sequence, the context size is the size of the target-sequence, and the context position is 1. DISCUSSION Note it is almost true that if the attribute name ends in "ref", it is evaluated in the in-scope context; otherwise in the element context (the one exception is @origin). AVTs: do we agree? (The spec examples are inconsistent, so we have to decide). Which of these two is right? <output ref="total" class="{if (total ge 0) then 'positive' else 'negative'}" /> <output ref="total" class="{if (. ge 0) then 'positive' else 'negative'}" /> How about with: <itemset model="flavors" ref="flavor" label="{description}" copy="description"/> (which is using (dynamic) element context). select/itemset/@copy: Element or in-scope? setindex/@index: Element or in-scope? insert/@at, delete/@at: I'm pretty sure that this means the element context. (I have my own feelings about these, but I don't want to prejudice your thinking). One other thing: I assume that it is right that context() returns the in-scope context as specified in https://www.w3.org/community/xformsusers/wiki/XPath_Expressions_Module#The_context.28.29_Function Steven
Received on Thursday, 15 December 2016 11:00:41 UTC