You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Fabrizio Morbini <fm...@gmail.com> on 2010/06/21 18:45:42 UTC

[scxml] templates

Hi, i would appreciate if somebody could clarify the working of
templates as exemplified here:

http://wiki.apache.org/commons/SCXML/Tutorials/Templating

i tried the following scenario:

===============file a.scxml:
<scxml id="SCXML" initial="start" xmlns="http://www.w3.org/2005/07/scxml">
 <state id="start">
  <transition event="start1" target="aa"></transition>
  <transition event="start2" target="aa"></transition>
 </state>
 <state id="aa" src="b.scxml#aa">
  <onentry></onentry>
  <onexit></onexit>
  <transition event="aa.done" target="end1"></transition>
 </state>
 <state id="aa" src="b.scxml#aa">
  <onentry></onentry>
  <onexit></onexit>
  <transition event="aa.done" target="end2"></transition>
 </state>
 <final id="end2"></final>
 <final id="end1"></final>
</scxml>

===============file b.scxml:
<scxml id="SCXML" xmlns="http://www.w3.org/2005/07/scxml">
 <state id="aa" initial="aa1">
  <final id="aa2"></final>
  <state id="aa1">
   <transition target="aa2"></transition>
  </state>
 </state>
</scxml>

When i load a.scxml in the executor, i get no errors or warnings.
However, the execution ends always with state "end2" no matter if i
send the event "start1" or the event "start2".
This suggests that nodes cannot use the same name, even though the
templating example seems to suggest that the same subnetwork can be
used in multiple locations without renaming the nodes.

if i rename the two nodes "aa" in a.scxml with "node1" and "node2" the
parsing of the file a.scxml fails with error:
ERROR 09:26:47.853 [main           ] [ModelUpdater             ]
Initial state null or not a descendant of state with ID "node1"

this suggests that, the naming of the node with the src attribute
influences how the content from the src url  is added to it. So i
changed the type of "node1" and "node2" to parallel and that solves
the parsing problem but doesn't produce the expected behavior:

sending the event "start2" i obtain the following execution trace:

DEBUG 09:33:57.749 [main           ] [sax                      ] endDocument()
DEBUG 09:33:57.758 [Thread-1       ] [Context                  ]
_eventdata = null
DEBUG 09:33:57.758 [Thread-1       ] [Context                  ]
_eventdatamap = {start.entry=null}
DEBUG 09:33:57.758 [Thread-1       ] [Context                  ]
_eventdata = null
DEBUG 09:33:57.758 [Thread-1       ] [Context                  ]
_eventdatamap = {start.entry=null}
DEBUG 09:33:57.758 [Thread-1       ] [SCXMLExecutor            ]
Current States: [start]
DEBUG 09:33:57.758 [main           ] [Context                  ]
_eventdata = null
DEBUG 09:33:57.758 [main           ] [Context                  ]
_eventdatamap = {start2=null}
DEBUG 09:33:57.759 [main           ] [Context                  ]
_eventdata = null
DEBUG 09:33:57.759 [main           ] [Context                  ]
_eventdatamap = {start.exit=null, node2.entry=null}
DEBUG 09:33:57.759 [main           ] [Context                  ]
_eventdata = null
DEBUG 09:33:57.759 [main           ] [Context                  ]
_eventdatamap = {start.entry=null}
DEBUG 09:33:57.759 [main           ] [SCXMLExecutor            ]
Current States: []

it seems that the content of node2 is never executed and end2 is not reached.

thanks,
fabrizio.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [scxml] templates

Posted by Rahul Akolkar <ra...@gmail.com>.
On Mon, Jun 21, 2010 at 12:45 PM, Fabrizio Morbini <fm...@gmail.com> wrote:
> Hi, i would appreciate if somebody could clarify the working of
> templates as exemplified here:
>
> http://wiki.apache.org/commons/SCXML/Tutorials/Templating
>
> i tried the following scenario:
>
> ===============file a.scxml:
> <scxml id="SCXML" initial="start" xmlns="http://www.w3.org/2005/07/scxml">
>  <state id="start">
>  <transition event="start1" target="aa"></transition>
>  <transition event="start2" target="aa"></transition>
>  </state>
>  <state id="aa" src="b.scxml#aa">
>  <onentry></onentry>
>  <onexit></onexit>
>  <transition event="aa.done" target="end1"></transition>
>  </state>
>  <state id="aa" src="b.scxml#aa">
>  <onentry></onentry>
>  <onexit></onexit>
>  <transition event="aa.done" target="end2"></transition>
>  </state>
>  <final id="end2"></final>
>  <final id="end1"></final>
> </scxml>
>
> ===============file b.scxml:
> <scxml id="SCXML" xmlns="http://www.w3.org/2005/07/scxml">
>  <state id="aa" initial="aa1">
>  <final id="aa2"></final>
>  <state id="aa1">
>   <transition target="aa2"></transition>
>  </state>
>  </state>
> </scxml>
>
> When i load a.scxml in the executor, i get no errors or warnings.
> However, the execution ends always with state "end2" no matter if i
> send the event "start1" or the event "start2".
> This suggests that nodes cannot use the same name, even though the
> templating example seems to suggest that the same subnetwork can be
> used in multiple locations without renaming the nodes.
>
<snip/>

The page you reference is a wiki page, is user-supplied content and is
open to editing to all users (after a brief account creation). Please
feel free to improve it if you can.

In general, ids of transition targets in a state machine need to be
unique. For example, in the document above, there are two states with
id "aa" so the parser (depending on the version) may simply overwrite
the object model and/or log a warning. Similarly, if the same content
is src'ed in from another document or document fragment multiple times
(as the example above does) and those documents or fragments contain
ids, there will be id clashes.


> if i rename the two nodes "aa" in a.scxml with "node1" and "node2" the
> parsing of the file a.scxml fails with error:
> ERROR 09:26:47.853 [main           ] [ModelUpdater             ]
> Initial state null or not a descendant of state with ID "node1"
>
<snap/>

Right, since the initial "aa1" no longer exists as a child.


> this suggests that, the naming of the node with the src attribute
> influences how the content from the src url  is added to it. So i
> changed the type of "node1" and "node2" to parallel and that solves
> the parsing problem but doesn't produce the expected behavior:
>
<snip/>

Didn't catch the connection to parallel above, but I see you have
posted a follow-up email as another thread, so I'll continue there.

-Rahul



> sending the event "start2" i obtain the following execution trace:
>
> DEBUG 09:33:57.749 [main           ] [sax                      ] endDocument()
> DEBUG 09:33:57.758 [Thread-1       ] [Context                  ]
> _eventdata = null
> DEBUG 09:33:57.758 [Thread-1       ] [Context                  ]
> _eventdatamap = {start.entry=null}
> DEBUG 09:33:57.758 [Thread-1       ] [Context                  ]
> _eventdata = null
> DEBUG 09:33:57.758 [Thread-1       ] [Context                  ]
> _eventdatamap = {start.entry=null}
> DEBUG 09:33:57.758 [Thread-1       ] [SCXMLExecutor            ]
> Current States: [start]
> DEBUG 09:33:57.758 [main           ] [Context                  ]
> _eventdata = null
> DEBUG 09:33:57.758 [main           ] [Context                  ]
> _eventdatamap = {start2=null}
> DEBUG 09:33:57.759 [main           ] [Context                  ]
> _eventdata = null
> DEBUG 09:33:57.759 [main           ] [Context                  ]
> _eventdatamap = {start.exit=null, node2.entry=null}
> DEBUG 09:33:57.759 [main           ] [Context                  ]
> _eventdata = null
> DEBUG 09:33:57.759 [main           ] [Context                  ]
> _eventdatamap = {start.entry=null}
> DEBUG 09:33:57.759 [main           ] [SCXMLExecutor            ]
> Current States: []
>
> it seems that the content of node2 is never executed and end2 is not reached.
>
> thanks,
> fabrizio.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org