summaryrefslogtreecommitdiffstats
path: root/test/samples/uscxml/test-prolog.scxml
blob: 8ccfd6b88f2c201cdd59c3c339b2dd21888482f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<scxml datamodel="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="s1">
    <onentry>
      <assign location="">
        retract(father(bob, jim)).
        assert(father(steve, jim)).
        assert(father(bob, jack)).
      </assign>
      <log label="index" expr="listing." />
      <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)"/>
  </state>
  <state id="s2">
    <onentry>
      <send type="basichttp"
            targetexpr="ioprocessors(basichttp(location(X)))"
            event="foo">
        <content>
          <p>Snippet of XML</p>
        </content>
      </send>
    </onentry>
    <transition 
      target="idle"
      event="foo"
      cond="member(element('p',_,_), X), event(data(X))" />
  </state>

	<state id="idle">
		<transition event="http.post" target="idle">
			<log expr="listing." />
			<respond status="200" to="event(origin(X))" />
		</transition>
		<transition event="http.post" cond="" target="idle">
			<log expr="listing." />
			<respond status="200" to="event(origin(X))" />
		</transition>
	</state>
	
  <state id="end" final="true" />
</scxml>