uscxml icon indicating copy to clipboard operation
uscxml copied to clipboard

including states defined in external xml files

Open crichardson332 opened this issue 4 years ago • 1 comments

We have a state machine up and running using uscxml as our interpreter, and it's working great. But now we would like to define a state machine across multiple files - namely, having a core scxml file that stays relatively constant for different scenarios, which then includes states and transitions defined in other xml files for mission specific things that change frequently.

Does uscxml support the xmlns:xi functionality of scxml? I've tried examples from the main scxml documentation with no luck, and I tried examples from this paper here on page 101. I tried defining ENTITY objects to pull in external xml files and that resulted in errors, and when I tried including a state via a line like this

<xi:include href="bathroom.scxml" />

the parser seems to just ignore the line and continue as if it doesn't exist. Even if the included file doesn't exist, the parser just skips over it and continues with no error

Does uscxml support any method of pulling in states defined elsewhere? Thanks!

crichardson332 avatar Jan 31 '20 22:01 crichardson332

XInclude

Method Interpreter Interpreter::fromXML does not support xinclude. But you may load resulting SCXML by yourself and then call Interpreter::fromElement or Interpreter::fromDocument.

Also you may use visual chart splitting. In this case you will have resulting common scxml but parts may be editted separately.

Pros:

  • Common datamodel (easy data sharing)
  • You may use 'In' predicate

Cons:

  • Difficult control of identifier uniqueness (state names, event identifiers etc.)
  • Not all parsers (SDKs) supports XInlcude

<invoke>

You may use <invoke> with content src as alternative.

Pros:

  • You may use multiple same invoke instances with passing individual params
  • Instance is isolated (you do not worry about same identifiers)

Cons:

  • Can not have common resources (every time copying data between sessions)
  • Can not use 'In' predicate for other instances

alexzhornyak avatar Feb 01 '20 08:02 alexzhornyak