Jump to: navigation, search

SCXML Language Reference

Click here to view the organization and contents of the SCXML Language Reference.

SCXML stands for State Chart XML: State Machine Notation for Control Abstraction. Orchestration Server utilizes an internally developed SCXML engine which is based on, and supports the specifications outlined in the W3C Working Draft 7 May 2009 [4]. There are, however, certain changes and/or notable differences (see Extensions and Deviations) between the W3C specification and the implementation in Orchestration Server which are described on this page. Only the ECMAScript profile is supported (the minimal and XPath profiles are not supported).


SCXML documents are a means of defining control behaviour through the design of state machines. The SCXML engine supports a variety of control flow elements as well as methods to manipulate and send/receive data, thus enabling users to create complex mechanisms.

For example, Orchestration, which is a consumer of the SCXML engine, uses SCXML documents to execute strategies. A simple strategy may involve defining different call routing behaviours depending on the incoming caller, however, the SCXML engine facilitates a wide variety of applications beyond simple call routing.

Authoring SCXML documents can be done using any text editor or by leveraging the Genesys Composer tool.

Syntax and Semantics

The appearance of an SCXML document is very similar to that of any other markup language. The use of various SCXML-specific tags define the structure and operation of a state machine. The SCXML snippet below illustrates how an SCXML document may look like in structure:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Specifying the encoding is important! -->

<scxml version="1.0" xmlns="http://www.w3.org/2005/07/scxml" 
        <transition target="FIRST_STATE">
            <log expr="'Inside the initial transition'" />

    <state id="FIRST_STATE">
            <log expr="'Do things here when state is first entered'" />
            <send event="LEAVE_STATE" />
            <log expr="'Do things here when state is being exited'" />
        <transition event="LEAVE_STATE" target="exit">
                var message = 'Do things here during a transition';
            <log expr="message" />

    <final id="exit" />

Basic Elements

SCXML elements for defining states, transitions, and behaviour include (but are not limited to):

  • <state>
  • <transition>
  • <parallel>
  • <initial>
  • <final>
  • <onentry>
  • <onexit>

In addition, it is also possible to define actions which are performed during state transitions (<onentry>, <onexit>, within <transition>) by using the following Executable Content elements (but are not limited to):

  • <if>/<elseif>/<else>
  • <foreach> (planned feature)
  • <raise>
  • <log>

It is also possible to embed script code (ECMAScript) within the state machine by using the following element:

  • <script>

One may refer to the W3C Working Draft[5] for more detailed explanations of the above elements and basic usage examples.

Managing Data

SCXML applications are commonly driven by data acquisition and manipulation, where the data gathered can be processed to determine application behaviour. Users may define data models within an SCXML document by using the <datamodel> element. A <datamodel> element may have any number of <data> elements as seen below:

    <data ID="target" expr="'Hello World!'" />
    <data ID="this_is_one" expr="1" />
    <data ID="m_array" expr="['a', 'b', 'c']" />

Any data objects defined in this manner become accessible as a child of the _data global object. To access a data object defined within a <datamodel>, the following syntax is used:

_data.data_ID    // Where data_ID is replaced by the ID of the data element

Alternatively, one may opt to declare data objects/variables within a <script> block instead if more complex initialization routines are required. Variables defined within a <script> block, however, become children of the <script> element's parent's local scope. That is, if it was defined in the global scope (<scxml>), the variables will be globally accessible; if it was defined within a state, the variables will become children of the state's local scope.

    var target='Hello World!';
    var this_is_one=1;
    var m_array = ['a', 'b', 'c'];
<log expr="'The value of target is: ' + target" />

Data sharing between SCXML sessions

It may be desirable in many situations to be able to share data between multiple SCXML sessions. Data may be shared between sessions using the following methods:

Session Initiated

When one SCXML session initiates another SCXML session via the <invoke> action (or <session:start>, <session:fetch>, which are specific to Orchestration only!) the initiating session can share data via the model defined in the SCXML specification. For details, see the <invoke> implementation section.

Session runtime

During the execution of a session, a session can shared data with another session via events and the <send> action.


Event handling (both internal and external) is fully supported by the SCXML engine. The event model allows users to control SCXML sessions by sending events from external entities or by raising events internally during the execution of an SCXML document. These events can be used to drive transitions or send data to external systems.

Internal Events

[+] Internal Events

External Events

[+] External Events

Common Properties for Internal and External Events

[+] Internal and External Events

Extensions and Deviations

The Genesys SCXML implementation introduces various additions and differences from the W3C SCXML specifications. The following extensions and deviations were introduced to accommodate the needs of the SCXML engine.


[+] ECMAScript

SCXML Elements

[+] SCXML Elements

Event Extensions

[+] Event Extensions

Logging and Metrics

[+] Logging and Metrics

Supported URI Schemes

[+] Supported URI Schemes

Supported Profiles

The SCXML engine supports only the ECMAScript profile. Other profiles (such as minimal or XPath) will not be supported.


[+] Examples
This page was last modified on November 22, 2018, at 04:45.


Comment on this article:

blog comments powered by Disqus