2

I am creating different SCXML files which are then used by a Qt application. In order to better structure my state machine, I would like to separate the common part of one machine from the custom state of every other machine. So I thought to split my state machine over 2 files.

Parent file: parentStateMachine.scxml

<?xml version="1.0" encoding="UTF-8"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml"
       version="1.0"
       binding="early"
       xmlns:qt="http://www.qt.io/2015/02/scxml-ext"
       name="MyStatemachine.scxml"
       qt:editorversion="4.2.2"
       datamodel="ecmascript"
       initial="s1"
       xmlns:xi="http://www.w3.org/2001/XInclude">
    <state id="init">
        <transition type="external" event="prepare" target="configure"/>
    </state>
    <state id="configure">
        <transition type="external" event="start" target="run"/>
    </state>
    <parallel id="run">
        <!-- include here application specific states-->
        <transition type="external" event="stop" target="end"/>
    </parallel>
    <final id="end">
    </final>
</scxml>

application specific: applicationSpecific1.scxml

<state id="applicationSpecificState1"/>
<state id="applicationSpecificState2"/>
<state id="applicationSpecificState3"/>

I have tried including the application specific within the parent one in 2 ways:

  1. I tried inserting <xi:include href="applicationSpecific1.xml"parse="text"/> instead of the comment.

  2. I tried adding <!DOCTYPE scxml [<!ENTITY innerFile SYSTEM "applicationSpecific1.scxml">]> right after the xml tag and then adding &innerFile; instead of the comment.

When I load the documents they are parsed fine but from the behavior I would deduce that it does not take into account whatever is defined in the application specific scxml.

PS: I have found this old unresolved bug report which I hope is already resolved. https://bugreports.qt.io/browse/QTBUG-1088

Matthew Kraus
  • 6,660
  • 5
  • 24
  • 31
Stefano
  • 3,981
  • 8
  • 36
  • 66
  • 1
    I can verify the same behavior with Qt 5.10. The SCXML spec gives an example of how to do this: https://www.w3.org/TR/scxml/#N11608. But unfortunately, this doesn't seem to be supported by Qt yet. – Matthew Kraus Dec 15 '17 at 02:08

0 Answers0