W3C home > Mailing lists > Public > www-voice@w3.org > January to March 2011

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

From: Johan Roxendal <johan@roxendal.com>
Date: Sat, 26 Feb 2011 13:36:54 +0100
To: www-voice@w3.org
Message-ID: <7475F78064794129A1331249C125D252@roxendal.com>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 26 February 2011 12:37:51 GMT