我遇到以下scxml代码的问题:
<?xml version="1.0" encoding="utf-8"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initialstate="global">
...
<state id="global" initial="init">
...
<state id="state2">
<onentry>
<if cond="mydata.skip">
<if cond="_event.name=='ev.prev'">
<raise event="ev.prev" />
<else/>
<raise event="ev.next" />
</if>
</if>
</onentry>
<transition event="ev.next" target="end" />
<transition event="ev.prev" target="state1" />
</state>
...
</state>
</scxml>
它工作正常但是当我添加了onentry元素时,proccessor会说以下内容:
[WARN] Ignoring element <raise> in namespace "http://www.w3.org/2005/07/scxml" at null:2:882 and digester match "scxml/state/state/onentry/if/if/raise"
[WARN] Ignoring element <raise> in namespace "http://www.w3.org/2005/07/scxml" at null:2:912 and digester match "scxml/state/state/onentry/if/if/else/raise"
似乎不理解加薪。我试图用'send'改变'raise'元素,我得到了类似的日志警告。谁能告诉我可能出错的地方?
感谢。
更新
我试图更改模式,避免嵌入if元素,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initialstate="global">
...
<state id="global" initial="init">
...
<state id="state2">
<onentry>
<if cond="mydata.skip and _event.name=='ev.prev'">
<raise event="ev.prev" />
<else if cond="mydata.skip and _event.name=='ev.next'"/>
<raise event="ev.next" />
</if>
</onentry>
<transition event="ev.next" target="end" />
<transition event="ev.prev" target="state1" />
</state>
...
</state>
</scxml>
但它也会出现以下错误:
[WARN] Ignoring element <raise> in namespace "http://www.w3.org/2005/07/scxml" at null:2:1057 and digester match "scxml/state/state/onentry/if/raise"
答案 0 :(得分:2)
我无法使加注事件发挥作用。但根据标准: http://www.w3.org/TR/scxml/#raise 你也可以使用发送活动。所以我尝试了,我可以做到这一点。
<state id="testID">
<onentry>
<send event="'test.onentry'" />
</onentry>
<transition event="test.transition" target="testID2"></transition>
</state>
按预期发送了test.onentry事件。但请注意那里双引号内的单引号!