SCXML: datamodel/script, the order of execution; late databinding behavior

according to the standard doc, the top-level datamodel element is evaluated at 'instantiation' time (http://www.w3.org/TR/scxml/#datamodel) and top-level script elements at 'document load time' (http://www.w3.org/TR/scxml/#script). from the interpret() function in the algorithm:

interpret(doc):
...
datamodel = new Datamodel(doc)
executeGlobalScriptElements(doc)
...
startEventLoop()


I drew the conclusion that the datamodel is evaluated before the script elements are executed. in retrospect, the above code really only says that the datamodel is instantiated, not evaluated, before the script element. 

Q1:
Which is the correct evaluation order of top-level datamodel and script elements?

Q2:
In the snippet:

<scxml datamodel="ecmascript" binding="late">
<state id="s1">
<onentry>
<log expr="data_slot" />
</onentry>
</state>
<state id="s2">
<datamodel>
<data id="data_slot" expr="0" />
</datamodel>
</state>
</scxml>

the log in state s1 will throw error.execution. now, same document with a few additions:

<scxml datamodel="ecmascript" binding="late">
<script>
var data_slot;
</script>
<state id="s1">
<onentry>
<log expr="data_slot" />
</onentry>
<transition target="s2" />
</state>
<state id="s2">
<datamodel>
<data id="data_slot" expr="0" />
</datamodel>
<onentry>
<log expr="data_slot" />
</onentry>
</state>
</scxml>

what will the second log statement print in this example? that is, does the data element overwrite the value of a slot that was given its initial value through the means of a script element?

thanks,
johan

Received on Saturday, 26 February 2011 12:37:45 UTC