Processing nested binds

At the recent call, you persuaded me I was wrong on this, so now I want to  
understand why I was wrong, so that I can fix the spec to make it clearer,  
so that others don't make the mistake I made.

So using the spec, I'll explain the steps I thought happened with <bind>,  
and I would be grateful if those of you who said I was wrong to point out  
the error of my thinking.

As an example I will use the following instance, and I am particularly  
interested in the nested <bind ref="b"/>

<model>
     <instance>
         <data xmlns="">
             <a><b/></a>
             <a><b/></a>
             <a><b/></a>
         </data>
     </instance>

     <bind ref="a" readonly="true()">
         <bind ref="b" type="integer"/>
     </bind>
<model>


Rebuild says:
"Each bind in the model is applied." [Note that this would include the  
nested bind]

The bind Element says:
"See Evaluation Context for details on how the evaluation context is  
determined for each attribute of the bind element."

Evaluation Context says:
"a binding element is any element that can have a binding attribute, while
a bound element is a binding element that explicitly has a binding
attribute."

"[If the binding of an element is expressed with the bind attribute, then
the resulting item or sequence is obtained from the referenced bind
element; otherwise] the in-scope evaluation context provides the default
evaluation context for a binding."

"For binding elements that have no ancestor binding elements, the initial
context size and position are 1, and the context item is the top-level
document element node of the default instance of the model referenced by
the model attribute, if any, otherwise of the containing model, if any,
and otherwise of the default model."

"For other binding elements, the nearest ancestor binding element is used:
...
If the ancestor expresses a Sequence Binding, then the context item is the
sequence's first item, the position is 1, and the size is the size of the
sequence. Additionally, an occurrence of the original binding element is
generated for each of the items in the sequence, with a dynamic in-scope
evaluation context that has a context item of the item of the sequence for
which the occurrence was generated, a size of the size of the sequence,
and a position of the position of the generated item in the sequence."

So expressing a context as <<elem, size, position>>:

The outermost bind has no ancestor; so its context is <<data, 1, 1>>
The innermost bind has an ancestor that expresses a sequence binding. So
the context is <<a[1], 3, 1>>.
Furthermore, the innermost bind is regenerated for each element of
the sequence:
     <<a[1], 3, 1>> <bind ref="b" type="integer"/>
     <<a[2], 3, 2>> <bind ref="b" type="integer"/>
     <<a[3], 3, 3>> <bind ref="b" type="integer"/>

So from my reading of the spec, without having to use the bit of spec that  
says
"For each item in the sequence, any child bind elements are recursively  
processed as described in the three points of this list.", the nested bind  
is already processed correctly.

What am I doing wrong?

Steven

Received on Tuesday, 6 December 2016 09:39:56 UTC