blob: 00865c4621cfa0e65afc23a6f72972c3075a5db0 (
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
<scxml datamodel="ecmascript" initial="start" binding="late" name="ptt"
xmlns="http://www.w3.org/2005/07/scxml"
xmlns:scenegraph="http://uscxml.tk.informatik.tu-darmstadt.de/scenegraph.xsd">
<script src="http://uscxml.tk.informatik.tu-darmstadt.de/scripts/dump.js" />
<datamodel>
<data id="foo">This is foo!</data>
</datamodel>
<state id="start">
<invoke type="scenegraph">
<content>
<scenegraph:display x="0" y="0" width="80%" height="80%">
<scenegraph:viewport x="0" y="0" width="100%" height="100%" bgcolor="grey" id="scene1">
<scenegraph:translation x="0" y="0" z="0">
<scenegraph:sphere radius="1" materialcolor="1.0,1.0,0,0.3" />
</scenegraph:translation>
<scenegraph:translation x="5" y="0" z="0">
<scenegraph:box x="1" y="2" z="3" color="red" />
</scenegraph:translation>
<scenegraph:translation x="0" y="5" z="0">
<scenegraph:capsule radius="1" height="2" materialcolor="blue"/>
</scenegraph:translation>
<scenegraph:translation x="0" y="0" z="5">
<scenegraph:cone radius="1" height="2" color="lightblue" />
</scenegraph:translation>
<scenegraph:translation x="0" y="-5" z="0">
<scenegraph:cylinder radius="1" height="2" color="orange" />
</scenegraph:translation>
</scenegraph:viewport>
</scenegraph:display>
</content>
</invoke>
<state id="main">
<transition event="http" target="main" type="internal"
cond="_event.data.pathComponent[1] === 'basichttp' &&
_event.data.pathComponent[2] === 'query'" >
<!-- a request for /ptt/basichttp/query -->
<script>dump(_event);</script>
<if cond="_event.data.header['X-XPath']">
<script>
// a xpath query, evaluate, check for result and set reply on event
var nodes = document.evaluate(_event.data.header['X-XPath']);
if (nodes.asNodeSet().size > 0) {
_event.reply = nodes.asNodeSet()[0];
} else {
_event.reply = "No nodes!";
}
</script>
<elseif cond="_event.data.header['X-ECMAPath']" />
<script>
// an ecmascript expression evaluate and set reply on event
_event.reply = eval(_event.data.header['X-ECMAPath']);
</script>
</if>
<send type="basichttp" targetexpr="_event.data.header['X-Reply-To']">
<content expr="_event.reply" />
</send>
</transition>
<transition event="http" target="main" type="internal"
cond="_event.data.pathComponent[1] === 'query'" >
<!-- a request for /ptt/query -->
<script>dump(_event);</script>
<if cond="_event.data.header['X-XPath']">
<script>
// a xpath query, evaluate, check for result and set reply on event
var nodes = document.evaluate(_event.data.header['X-XPath']);
if (nodes.asNodeSet().size > 0) {
_event.reply = nodes.asNodeSet()[0];
} else {
_event.reply = "No nodes!";
}
</script>
<elseif cond="_event.data.header['X-ECMAPath']" />
<script>
// an ecmascript expression evaluate and set reply on event
_event.reply = eval(_event.data.header['X-ECMAPath']);
</script>
</if>
<respond to="_event.origin">
<content expr="_event.reply" />
</respond>
</transition>
</state>
</state>
</scxml>
|