summaryrefslogtreecommitdiffstats
path: root/test/uscxml/test-prolog.scxml
diff options
context:
space:
mode:
Diffstat (limited to 'test/uscxml/test-prolog.scxml')
-rw-r--r--test/uscxml/test-prolog.scxml89
1 files changed, 89 insertions, 0 deletions
diff --git a/test/uscxml/test-prolog.scxml b/test/uscxml/test-prolog.scxml
new file mode 100644
index 0000000..a0a79cb
--- /dev/null
+++ b/test/uscxml/test-prolog.scxml
@@ -0,0 +1,89 @@
+<scxml datamodel="prolog" name="outer">
+ <!-- a nested SCXML interpreter with prolog -->
+
+ <datamodel>
+ <data src="" />
+ <data id="father">
+ bob, jim.
+ bob, john.
+ </data>
+ <data id="">
+ mother(martha, jim).
+ mother(martha, john).
+ </data>
+ <data id="household">
+ {
+ name: "The Bobsons",
+ members: ['bob', 'martha', 'jim', 'john']
+ }
+ </data>
+ <data id="childs">
+ <child name="jim" father="bob" />
+ <child name="john" father="bob" />
+ </data>
+ </datamodel>
+ <state id="start">
+ <!-- invoke type="http://www.w3.org/TR/scxml/" autoforward="true">
+ <content>
+ <scxml datamodel="prolog" name="inner">
+ <state id="idle">
+ <onentry>
+ <log label="Entering inner" />
+ <send target="#_parent" event="inner" />
+ </onentry>
+ <transition target="end" event="foo" />
+ <transition type="internal" event="*" target="idle">
+ <log label="invoked" expr="event(name(X))." />
+ </transition>
+ </state>
+ <state id="end" final="true" />
+ </scxml>
+ </content>
+ </invoke -->
+
+ <state id="s1">
+ <onentry>
+ <log label="Entering s1" />
+ <script>
+ :- dynamic ampel/1.
+ ampel(false).
+ ampel(X) :- retract(ampel(_)), assertz(ampel(X)).
+ </script>
+ <script type="query">
+ ampel(true).
+ </script>
+ <assign location="">
+ retract(father(bob, jim)).
+ assert(father(steve, jim)).
+ assert(father(bob, jack)).
+ </assign>
+ <log label="foreach" />
+ <foreach array="father(bob, X)"
+ item="child"
+ index="index">
+ <log label="index" expr="index(X)" />
+ <log label="child" expr="child(X)" />
+ </foreach>
+ </onentry>
+ <transition target="s2"
+ cond="mother(martha, X), father(bob, X), in(s1)"/>
+ </state>
+ <state id="s2">
+ <onentry>
+ <log label="Entering s2" />
+ <send type="basichttp"
+ targetexpr="ioprocessors(basichttp(location(X)))"
+ event="foo">
+ <content>
+ <p>Snippet of XML</p>
+ </content>
+ </send>
+ </onentry>
+ <transition
+ target="end"
+ event="foo"
+ cond="member(element('p',_,_), X), event(data(X))" />
+ </state>
+ </state>
+ <state id="end" final="true" />
+</scxml>