Re: ACTION-2342: Spec the event communication for further discussion.

Working towards this specification, I came across some discussion 
questions.


Data communication, which happens via the mutual @ref on the <control/> and 
<interface/>

Parent:
<control id="child" resource="child.xhtml" ref="instance('data')/common"/>

Child:
<interface id="parent" ref="instance('values')/shared"/>

During processing the two (sub-)instances are shared. A change in one 
appears as an equivalent change in the other, in either direction.

How do we define whether the parent or child initialises the sub-instance? 
My feeling is that the child should be in control: it specifies what it 
expects; so on the interface element there should be some indication 
whether it is initialised from outside or not. We can make one the default, 
so you only have to specify the other. I feel that no initialisation from 
outside should be the default (since that is the default when there is no 
<interface/> element anyway).

How should initialisation work? I suspect something like for targetref in 
submission. 
https://www.w3.org/community/xformsusers/wiki/XForms_2.0#Replacing_Data_with_the_Submission_Response
  

The incoming data overwrites the part of the instance marked in the 
<interface/> element, if initialised from outside, and the child 
sub-instance replaces the parent sub-instance otherwise.

Do we have to say about anything about the shape of the two sub-instances 
then? There's not much for targetref under submission. Require it to be an 
element?

===================================

Some Examples. I haven't yet come to a conclusion about how to signal how 
the child instance should be initialised, so used init="parent" as a 
placeholder.

Embedding a form that just outputs the date:

Parent: <control resource="date.xhtml" label="Today's date and time"/>
Child (has no <interface/> element: <output value="now()"/>

===================================
Selecting a game to play:

<select1 ref="game" label="select a game to play">
   <item label="minesweeper">minesweeper.xml</item>
   <item label="slider">slider.xml</item>
   <item label="noughts and crosses">xox.xml</item>
</select1>
<control resource="{game}"/>

Children have no interface element

===================================

Histograms

Parent:

<instance>
   <data xmlns="">
      <before>
         <y>9</y><y>15</y><y>11</y><y>6</y><y>5</y><y>10</y><y>8</y>
      </before>
      <after>
         <y>8</y><y>3</y><y>12</y><y>14</y><y>9</y><y>16</y><y>14</y>
      </after>
   </data>
</instance>
...
<control resource="histogram.xhtml" ref="before" label="Then"/>
<control resource="histogram.xhtml" ref="after"  label="Now"/>

Child: 
<interface ref="data" init="parent"/>

Presumably what is referenced as before/y in the parent is referencd as 
data/y in the child

===================================
A child not being initialised

Parent:

<instance>
   <data xmlns="">
      <testfile>test.xml</testfile>
   </data>
</instance>

<instance id="results"/>
...
<control ref="instance('results')" resource="{testfile}"/>

Child:

<instance>
   <data xmlns="">
      <values>...</values>
      <results>
         <percent/>
         <success/>
         <failure/>
      </results>
   </data>
</instance>

<interface ref="data"/>


===================================
A child being initialised

Parent: 

<instance id="data">
   <data xmlns="">
      <values>
         <a>1</a>
         <b>2</b>
         <c>3</c>
      </value>
      <sum/>
   </data>
</instance>
...
<control ref="instance('data')" resource="add.xhtml"/>
<output ref="instance('data')/sum"/>

In add.xhtml:

<instance>
   <input xmlns=""/>
</instance>
<interface ref="/input" init="parent"/>
<bind ref="sum" calculate="sum(values/*)"/>

===================================
A child that displays a map to set a location

Parent:

<instance>
   <locations xmlns="">
      <home x="" y=""/>
      <dest x="" y=""/>
   </locations>
</instance> ...
<control ref="home" resource="map.xf" label="Please locate your home 
location"/>
<control ref="dest" resource="map.xf" label="Please locate your 
destination"/>

Child:
<instance id="result">
     <result xmlns=""/>
</instance>
<interface ref="instance('result')"/>

===================================
Testsuite

<instance> 
   <testsuite xmlns="">
      <testcase>
         <filename>boolean-from-string.xml</filename>
         <tests>
            <test res="" req="true">1</test>
            <test res="" req="false">0</test>
            <result/>
         </tests>
      </testcase>
      <testcase>
         ...
      </testcase>
   </testsuite>
</instance>
<repeat ref="testcase">
   <control resource="{filename}" ref="tests"/>
</repeat>

Child:
<model>
   <instance>
      <tests xmlns=""/>
   </instance>
  
  <interface ref="tests" init="parent"/>
</model>

===================================

Steven

Received on Friday, 16 June 2023 13:37:15 UTC