Copyright
© 2008 © 2009
W3C ® ® ( MIT ,
ERCIM
, Keio ), All Rights Reserved.
W3C liability
, trademark
and document
use rules apply.
This document describes SCXML, or the "State Chart extensible Markup Language". SCXML provides a generic state-machine based execution environment based on CCXML and Harel State Tables.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
This document is the fourth
fifth Public Working Draft of SCXML
published on 16 7 May 2008 2009 for review by W3C Members and other
interested parties, and has been developed by the Voice Browser Working Group as part
of the W3C Voice
Browser Activity . The main differences from the previous draft
are: the modularization of the language the
introduction of profiles and are
a revision of the algorithm for document
interpretation. Please note that most sections have been modified
because of above changes, <send>
and <invoke> elements and the editors would like readers introduction of Event I/O processors to
read the whole document carefully and give
comments. support them.
Comments for this specification are welcomed to www-voice@w3.org ( archives ).
Publication as a Working Draft does not
imply endorsement by the W3C Membership. This is a draft document
and may be updated, replaced or obsoleted by other documents at any
time. It is inappropriate to cite this document as other than work
in progress. This document was produced by a group operating
under the 5 February
2004 W3C Patent Policy . W3C maintains a public list of any
patent disclosures made in connection with the deliverables of
the group; that page also includes instructions for disclosing a
patent. An individual who has actual knowledge of a patent which
the individual believes contains
Essential Claim(s) must disclose the information in accordance
with
section 6 of the W3C Patent Policy .
Policy.
Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
1 Terminology
2 Overview
3 Core Module
3.1 <scxml>
3.1.1 Attribute Details
3.1.2 Children
3.2 <state>
3.2.1 Attribute Details
3.2.2 Children
3.3 <transition>
3.3.1 Attribute Details
3.3.2 Children
3.3.3
Selecting and Executing
Transitions
3.4 <parallel>
3.4.1 Attribute Details
3.4.2 Children
3.5 <initial>
3.5.1 Attribute Details
3.5.2 Children
3.6 <final>
3.6.1 Attribute Details
3.6.2 Children
3.7 <onentry> <donedata>
3.7.1 Attribute Details
3.7.2 Children
3.8 <onexit> <content>
3.8.1 Attribute Details
3.8.2 Children
3.9 <history> <onentry>
3.9.1 Attribute Details
3.9.2 Children
3.10 <onexit>
3.10.1
Attribute
Details
3.10.2
Children
3.11 <history>
3.11.1
Attribute
Details
3.11.2
Children
3.12 Executable Content
3.10.1
3.12.1
<event>
<raise>
3.10.1.1
3.12.1.1
Attribute Details
3.10.1.2
3.12.1.2
Children
3.10.2
3.12.2
<if>
3.10.2.1
3.12.2.1
Attribute Details
3.10.2.2
3.12.2.2
Children
3.10.3
3.12.3
<elseif>
3.10.3.1
3.12.3.1
Overview
3.10.3.2
3.12.3.2
Attribute Details
3.10.4
3.12.4
<else>
3.10.4.1
3.12.4.1
Overview
3.10.4.2
3.12.4.2
Attribute Details
3.10.5
3.12.5
<log>
3.10.5.1
3.12.5.1
Overview
3.10.5.2
3.12.5.2
Attribute Details
3.10.6
3.12.6
Extensibility of Executable
Content
3.11
3.13 Referencing External Files
3.12
3.14 SCXML Events
4 External Communications
Module
4.1 <send>
4.1.1 Overview
4.1.2 Attribute Details
4.1.3
Children
4.2 <invoke> <cancel>
4.2.1 Attribute Details
4.2.2 Children
4.3 <param> <invoke>
4.3.1 Attribute Details
4.3.2 Children
4.4 <finalize>
4.4.1 Attribute
Details 4.3.3
Data
Sharing
4.4.2
Children 4.3.4
Implementation
4.5
<content> 4.4 <finalize>
4.5.1
4.4.1
Attribute Details
4.5.2
4.4.2
Children
5 Data Module
5.1 <datamodel>
5.1.1 Attribute Details
5.1.2 Children
5.2 <data>
5.2.1 Attribute Details
5.2.2 Children
5.3 <assign>
5.3.1 Attribute Details
5.3.2 Children
5.4 <validate>
5.4.1 Attribute Details
5.4.2 Children
5.5 <param>
5.5.1
Attribute
Details
5.5.2
Children
5.6 System Variables
5.6.1
The
Internal Structure of Events
6 Script Module
6.1 <script>
6.1.1 Attribute Details
6.1.2 Children
7 Anchor Module
7.1 <anchor>
7.1.1 Attribute Details
7.1.2 Children
8 Expressions
8.1 Conditional Expressions
8.2 Location
Expressions
8.3 Legal Data
Values and Value Expressions
8.4 Errors
in Expressions
9 Profiles
9.1 The Minimal
Profile
9.1.1 Conformance
9.1.2 Core Module Requirements
9.1.2.1
Conditional Expressions
9.2 The ECMAScript
Profile
9.2.1 Conformance
9.2.2 Core Module Requirements
9.2.2.1
Conditional Expressions
9.2.3 Data Module Requirements
9.2.3.1
Location Expressions
9.2.3.2
Value Expressions
9.2.3.3
System Variables
9.2.4 Script Module Requirements
9.2.5 Additional Requirements
9.2.5.1
The In() predicate
9.2.6 Examples
9.3 The XPath
Profile
9.3.1 Conformance
9.3.2 Core Module Requirements
9.3.2.1
Conditional Expressions
9.3.3 Data Module Requirements
9.3.3.1
Location Expressions
9.3.3.2
Value Expressions
9.3.3.3
System Variables
9.3.4 Additional Requirements
9.3.4.1
The In() scxml:In() predicate
9.3.4.2
The instance() function
9.3.5 Examples
10 Related Work
A Open Issues
A.1 Event
Processors Iterative
Construct
A.2 Alternative
Notation
A.3 parallel transition
order
A.4 error
handling
A.5 do we need
<returndata> Initial transition leading to a history
state
B Algorithm for SCXML
Interpretation
B.1 Semantics
of <anchor>
C Probabilistic State Machines
D Schemas
D.1 Utility
Schemas
D.2 Schema for Core
Module
D.3 Schema for External
Module
D.4 Schema for Data
Module
D.5 Schema for
Script Module
D.6 Anchor Module
Schema
D.7 Minimal
Profile Schema
D.8 ECMAScript
Profile Schema
D.9 XPath Profile
Schema
D.10 SCXML Message
Schema
E Examples
E.1 Language
Overview
E.2 Shale
Example
E.3 Examples of Invoke
and finalize
E.4 Custom Action
Elements
F Conformance
G SCXML Event
I/O Processor
G.1 Examples
H Basic HTTP Event
I/O Processor
H.1 Access URI
H.2 Receiving Events
H.3 Sending Events
I References
[ Definition : The key words must , must not , required , shall , shall not , should , should not , recommended , may , and optional in this specification are to be interpreted as described in [IETF RFC 2119] .]
The terms base URI and relative URI are used in this specification as they are defined in [IETF RFC 2396] .
This document outlines State Chart XML (SCXML), which is a general-purpose event-based state machine language that can be used in many ways, including:
SCXML combines concepts from CCXML and Harel State Tables. CCXML [W3C CCXML 1.0] is an event-based state machine language designed to support call control features in Voice Applications (specifically including VoiceXML but not limited to it). The CCXML 1.0 specification defines both a state machine and event handing syntax and a standardized set of call control elements. Harel State Tables are a state machine notation that was developed by the mathematician David Harel [Harel and Politi] and is included in UML [UML 2.0] . They offer a clean and well-thought out semantics for sophisticated constructs such as a parallel states. They have been defined as a graphical specification language, however, and hence do not have an XML representation. The goal of this document is to combine Harel semantics with an XML syntax that is a logical extension of CCXML's state and event notation.
SCXML is defined in terms of modules, which define logical units of functionality. Modules are customized and combined into profiles, each of which can be thought of as defining a variant of the language. This modularity allows implementations flexibility in selecting the features that they want to support. It is particularly intended to allow them the choice of which data manipulation language (e.g., ECMAScript, XPath) to embed. At this point, only support for the most limited profile (see 9.1 The Minimal Profile ) is mandatory. Support for all other profiles is optional, though this may change in future versions of the specification.
The Core Module contains the elements that define the basic Harel state machine. The Core Module can be used by itself (see 9.1 The Minimal Profile ), but it will not be able to communicate with external entities or maintain an internal data model. The schema for the core module can be found at D.2 Schema for Core Module .
The top-level root state, which carries version information etc.
Name | Required | Attribute Constraints | Type | Default Value | Valid Values | Description |
---|---|---|---|---|---|---|
initial | false | IDREFS | none | The IDs of one or more state or parallel elements contained in
this state |
The id of the initial state(s) for the document. This attribute is shorthand for an <initial> child with a transition containing an unconditional transition. | |
name | false | NMTOKEN | none | Any valid NMTOKEN | The name of this state machine. It is for purely informational purposes. | |
xmlns | false | URI | none | If specified, the value must be "http://www.w3.org/2005/07/scxml". | ||
version | true | decimal | none | The only legal value is "1.0" | ||
profile | false | NMTOKEN | none | "minimum", "ecmascript", "xpath" or other platform-defined values. | The SCXML profile that this document requires. "min" denotes the Minimal Profile, "ecma" the ECMAScript Profile, and "xpath" the XPath Profile, as defined in 9 Profiles . | |
exmode | false | NMTOKEN | "lax" | "lax" or "strict" | The execution mode of the interpreter. This defines how the interpreter should behave if it encounters an element or attribute that it does not understand. If exmode is "lax", the interpreter will silently ignore element or attribute. If exmode is "strict", the interpreter still not process the element or attribute, but will also raise the error error.unsupportedelement. |
A state machine must specify either an "initial" attribute or an
<initial> element, but not both. Either notation can be used
to specify the state that the machine will transition to at the
start of processing. The only difference between the two notations
is that the <initial> element contains a <transition>
element which may in turn contain executable content which will be
executed before the initial state is entered. If the "initial" attribute is specified instead, the
specified state will be entered, but no executable content will be
executed.
Holds the representation of a state.
Name | Required | Attribute Constraints | Type | Default Value | Valid Values | Description |
---|---|---|---|---|---|---|
id | true | ID | none | A valid id as defined in [XML Schema] | The identifier for this state. It MUST be unique within the document. | |
src | false | URI | none | Any URI | URI of a file containing material to be inserted into this
state. See |
|
initial | false | IDREFS | none | The IDs of one or more state or parallel elements contained in this state. If the IDs of multiple states or parallel elements are specified, they must all be children of a common <parallel> ancestor. | The id of the default initial state (or states) for this state. This attribute is shorthand for an <initial> child containing an unconditional transition. |
A complex state, namely one that has <state> or <parallel> children, must specify either an "initial" attribute or am <initial> element, but not both. Either notation can be used to specify the state's default initial state. See 3.5 <initial> for a discussion of the difference between the two notations.
Transitions between states are triggered by events and
conditionalized via guard-conditions. The optional attribute
"target" specifies the destination of the transition, which may be
a <state> or a <parallel> region. If the "target" on a <transition> is omitted, then
taking the transition has the effect of leaving the machine in the
same state after invoking any executable content that is included
in the transition. Such a transition is equivalent to an 'event'
handler in Harel State Table notation. Note that this is different
from a <transition> whose "target" is its source state. In
the latter case, the state is exited and reentered, triggering
execution of its <onentry> and <onexit> executable
content. Any executable content contained in a transition is
executed after the <onexit> handlers of the source state and
before the <onentry> handlers of the target state.
Name | Required | Attribute Constraints | Type | Default Value | Valid Values | Description |
---|---|---|---|---|---|---|
event | false | NMTOKEN | none | Any event name. The wildcard '*' is permitted. See |
The event trigger for this transition. The transition will be
taken only when the event is generated. |
|
cond | false | Boolean expression | none | Any boolean expression. | Guard condition for this transition. If it is present, the
transition is taken only if the guard condition evaluates to
true . See 8.1
Conditional Expressions for details. |
|
target | false | IDREFS | none | Whitespace separated list of state IDs in the current state machine. If multiple states are specified all must be descendants of the same <parallel> element. | The identifier(s) of the state or parallel region to transition to. If it is omitted, the transition will not cause a change in the state configuration when it is executed. The executable content contained in the transition will still be executed, so the transition will function as a simple event handler. If the target is present and equal to the state containing the transition element, the transition will cause the state machine to leave and then re-enter this state. | |
anchor | false | NMTOKEN | none | Any anchor type | The type of the anchor to transition to. See 7.1 <anchor> for details. |
Only one of "target" and "anchor" may be specified.
If a transition has both "event" and "cond" attributes, it will
be taken only if an event is raised that whose name
matches the "event" pattern attribute (see 3.14 SCXML Events for details) and the "cond" condition evaluates to
true. If the "event" clause is missing, the transition is taken
whenever the "cond" evaluates to true. If the "cond" clause is also
empty, the transition is taken as soon as the state is entered.
When looking for transitions, the state machine first looks in the most deeply nested active state(s), i.e., in the atomic state(s) that have no substates. If no transitions match in the atomic state, the state machine will look in its parent state, then in the parent's parent, etc. Thus transitions in ancestor states serve as defaults that will be taken if no transition matches in a descendant state. If no transition matches in any state, the event is discarded. If in any state more than one transition matches, the first one in document order will be taken. Thus, in the following example, the system will transition to s1 when event e occurs if x is equal to 1, but will transition to s2 if event e occurs and x is not equal to 1, and will go to s3 if any event other than e occurs.
<state id=s"> <transition event="e" cond="x==1" target="s1"/> <transition event="e" target="s2"/> <transition event="*" target="s3"/> </state>
Note that the data model can be changed only by the execution of <invoke> or executable content. Therefore transitions with empty "event" conditions need be checked only 1) upon arrival into a state, after the completion of all <onentry> handlers and 2) after an event has been processed (since it may have triggered executable content which could have updated the data model). See B Algorithm for SCXML Interpretation for details.
The behavior of a transition is defined in terms of the set of active states, the transition's source state, which is the state that contains the transition, and the transition's target state(or states). (If the transition's target is inside a <parallel> region, it may have multiple target states, otherwise it will have a single one.) The least common ancestor (LCA) of a transition is defined to be the innermost <state>, <parallel> or <scxml> element that is a proper ancestor of the transition's source state and its target state(s). When a transition is taken, all active states that are proper descendants of the LCA are exited, starting with the innermost one(s) and working up to the immediate descendant(s) of the LCA. Then the state machine enters the target state(s), plus any states that are between it and the LCA, starting with the outermost one (i.e., the immediate descendant of the LCA) and working down to the target state(s). As states are exited, their <onexit> handlers are executed. Then the executable content in the transition is executed, followed by the <onentry> handlers of the states that are entered.
In the example below, assume that state s11 is active when event 'e' occurs. The source of the transition is state s1, its target is state s21, and the LCA is state S. When the transition is taken, first state S11 is exited, then state s1, then state s1 is entered, then state s21. Note that the LCA S is neither entered nor exited. For more details see B Algorithm for SCXML Interpretation .
<state id="S" initial="s1"> <state id="s1" initial="s11"> <onexit> <log expr="'leaving s1'"/> </onexit> <state id="s11"> <onexit> <log expr="'leaving s11'"/> </onexit> </state> <transition event="e" target="s21"> <log expr="'executing transition'"/> </transition> </state> <state id="s2" initial="s21"> <state id="s21"> <onentry> <log expr="'entering s21'"/> </onentry> </state> <onentry> <log expr="'entering s2'"/> </onentry> </state> <onentry> <log expr="'entering S'"/> <onentry> <onexit> <log expr="'leaving S'"/> <onexit> </state> ==== log output will be ======> leaving s11 leaving s1 executing transition entering s2 entering s21
If the "target" on a <transition> is omitted, then taking the transition has the effect of leaving the machine in the same state after invoking any executable content that is included in the transition. Such a transition is equivalent to an 'event' handler in Harel State Table notation. Note that this is different from a <transition> whose "target" is its source state. In the latter case, the state is exited and reentered, triggering execution of its <onentry> and <onexit> executable content.
A state that encapsulates a set of parallel states
. The <parallel> element has <onentry> and
<onexit> and <transition> elements analogous to
<state>. In addition, the <parallel> element holds a
set of <state> elements that execute in parallel and join at
the <onexit> handler of the <parallel> element. In
particular, when all of the parallel substates reach final states,
a completion event "ID.done"
done.state. id is generated, where "ID" id is
the "id" id
of the <parallel> element. Either the <parallel>
element or one of its ancestors can trigger a transition off this
event, at which time the <onexit> handler of the element will
be executed.
When the state machine enters the parent <parallel> state, it simultaneously enters each child state. Transitions within the individual child elements operate normally. However any of the child elements may take a transition outside the <parallel> element. When this happens, the <parallel> element and all of its child elements are exited and the corresponding <onexit> handlers are executed. The handlers for the child elements execute first, in document order , followed by those of the parent <parallel> element, followed by an action expression in the <transition> element, and then the <onentry> handlers in the "target" state. See B Algorithm for SCXML Interpretation for a detailed description of the semantics <parallel> and the rest of SCXML.
Name | Required | Attribute Constraints | Type | Default Value | Valid Values | Description |
---|---|---|---|---|---|---|
id | true | ID | none | A valid id as defined in [XML Schema] | The identifier for this state. It MUST be unique within the document. | |
src | false | URI | none | Any URI | URI of a file containing material to be inserted into this
state. See |
This element represents the default initial state for a complex state with sequential substates. Suppose <state> S1 has child states S11, S12, and S13. If the system is in S1, it must also be in one (and only one) of S11, S12, or S13. A <transition> in a distinct <state> S2 may take S11, S12, or S13 as its "target", but it may also simply specify the parent S1. In that case, the <initial> child of S1 specifies which of S11, S12, or S13 the system should transition to.
The only difference between the <initial> element and the 'initial' attribute is that the <initial> element contains a <transition> element which may in turn contain executable content which will be executed before the default state is entered. If the "initial" attribute is specified instead, the specified state will be entered, but no executable content will be executed. As an example, suppose that parent state S contains child states S1 and S2. If S specifies S1 as its default initial state via the "initial" attribute, then any transition that specifies S as its target will result in S entering S1 as well as S. In this case, the result is exactly the same as if the transition had taken S1 as its target. If, on the other hand, S specifies S1 as its default initial state via the <initial> tag containing a <transition> with S1 as its target, the <transition> can contain executable content which will execute before the default entry into S1. In this case, there is a difference between a transition that takes S as its target and one that takes S1 as its target. In the former case, but not in the latter, the executable content inside the <initial> transition will be executed.
<final> represents repesents a final state of a compound state. When
the system state
machine reaches a final
<final> child of a compound
state, it means that its parent
the compound state has completed its
activity. Upon entry to the final state, after completion of the <onentry> elements,
the event "ParentID.done" done.state. parentid is generated, where 'ParentID' parentid is the ID id of the parent
compound state. Note that even though
the parent state has run to completion, more remote ancestors may
still be active. When the state machine reaches a top-level final
state (namely one that is a child of <scxml>), it has
finished processing and will terminate. In
this case, no event is generated unless the session was triggered
as the result of an <invoke> element in another session. In
this case, the event done.invoke.state. invokeid is generated
and returned to the other session, where invokeid is the unique
identifier generated when the <invoke> element was executed.
See 4.3
<invoke> for
details.
Name | Required | Attribute Constraints | Type | Default Value | Valid Values | Description |
---|---|---|---|---|---|---|
id | true | ID | none | A valid id as defined in [XML Schema] | The identifier for this state. It MUST be unique within the document. |
A wrapper element holding data to be included in the 'done' event that is generated when a <final> state is entered. The exact format of the data will be determined by the profile (see 9 Profiles for details). <param> may not occur in documents whose profile does not contain the Data Module.
<donedata> may have one or more <param> children or a single <content> child, but not both.
The <content> element provides a general way of specifying in-line data. It can be used to identify data to be included in an event or to be passed to an external service.
The child elements of <content> consist of arbitrary markup which will be passed unmodified. The markup may consist of text, XML from any namespace, or a mixture of both.
Profiles that contain the Data Module may also use 5.5 <param> to compute such data dynamically.
The children of the <onentry> handler consist of
executable content as defined in 3.10 3.12 Executable Content
The children of the <onexit> handler consist of executable
content as defined in 3.10 3.12 Executable
Content
The <history> pseudo-state allows for 'pause and resume' control flow. Whenever a complex <state> is exited, its <history> pseudo-state, if present, records the state configuration at exit. Later a <transition> taking the <history> state as its "target" allows the <state> to pick up where it left off. If the state containing the <history> state is a compound state, then the history value will be a single state. However, if the parent state is a <parallel> state, the history value will be a set of states, one for each parallel child region.
Name | Required | Attribute Constraints | Type | Default Value | Valid Values | Description |
---|---|---|---|---|---|---|
id | true | ID | none | A valid id as defined in [XML Schema] | Identifier for this pseudo-state. It MUST be unique within the document. | |
type | false | NMTOKEN | shallow | "deep" or "shallow" | If the value is 'shallow' then this state records only the immediate children of the parent <state>. In this case a <transition> with the history pseudo-state as its "target" will end up in the immediate child state that the parent was in the last time it was exited. On the other hand, if this attribute is set to 'deep', the history pseudo-state will remember nested states. In this case a <transition> with the history pseudo-state as its "target" will end up in the most deeply nested descendant <state> the parent was in the last time it was exited. |
Executable content consists of actions that are performed as
part of taking transitions and entering and leaving states
(<onentry> and <onexit>, etc.) Executable content
occurs in blocks, meaning that wherever executable content may
occur, an arbitrary number of elements may occur. These elements in
a block are processed in document order. If the processing of an
element causes an error to be raised, the remaining remaing
elements of the block are not processed and the error event is
placed on the internal event queue and processed like any other
event (see B
Algorithm for SCXML Interpretation ). In particular, the
error event will not be removed from the queue and processed until
all events preceding preceeding it in the queue have been
processed.
Note that 4 External Communications Module , 5 Data Module and 6 Script Module all define additional elements of executable content beyond those listed here. Thus the exact set of executable content available depends on the profile (see 9 Profiles for examples).
The <event> <raise> element may be used to raise an
event in the current SCXML session. The event will be added to the
session's internal event queue, but will not be processed until
later, following the algorithm specified in B Algorithm for SCXML
Interpretation . Note in particular that the event cannot
be processed until all current executable content has been
executed. For example, if the <event> <raise> element occurs in the the
<onentry> handlers of a state, at the very least the event
will not be processed until all the executable content in the
<onentry> handler has completed.
Name | Required | Attribute Constraints | Type | Default Value | Valid Values | Description |
---|---|---|---|---|---|---|
true | NMTOKEN | none | Specifies the name of the event. This will be matched against the 'event' attribute of transitions. |
None. <raise> may have one or more <param>
children or a single <content> child, but not both. The exact
format of the data included in the event will be determined by the
profile (see 9
Profiles for details).
<param> may not occur in documents whose profile does not
contain the Data Module.
The 4.1 <send> element may also be used to raise internal events in an SCXML session. The <send> is a general-purpose message element, while <raise> has a simpler syntax. Furthermore, because the 'event' attribute of <raise> is of type NMTOKEN rather than a dynamically evaluated value expression, markup using <raise> may be analyzed statically.
<if> is a container for conditionally executed elements. <elseif> and <else> can optionally appear within an <if> as immediate children, and serve to partition the elements within the <if>. <else> and <elseif> have no content. <else/> is equivalent to an <elseif > element whose "cond" always evaluates to true.<else> must occur after all <elseif> tags.
Each partition within an <if> is preceded by an element having a "cond" attribute. The initial partition is preceded by the <if> and subsequent partitions by <elseif>s (or <else>). The first partition in document order with a "cond" that evaluates to true is selected. <else> always evaluates to true. A partition MAY be empty.
If an <if> has no immediate <elseif> or <else> children, the full contents of the <if> will be selected when the "cond" attribute evaluates to true.
<else> was chosen to match similar concepts in other languages, and supports examples such as
<if cond="cond1"> <!-- selected when "cond1" is true --> <elseif cond="cond2"/> <!-- selected when "cond1" is false and "cond2" is true --> <elseif cond="cond3"/> <!-- selected when "cond1" and "cond2" are false and "cond3" is true --> <else/> <!-- selected when "cond1", "cond2", and "cond3" are false --> </if>
Name | Required | Attribute Constraints | Type | Default Value | Valid Values | Description |
---|---|---|---|---|---|---|
cond | true | Conditional expression | none | A valid conditional expression | A boolean expression. See 8.1 Conditional Expressions for details. |
An <elseif> partitions the content of an <if>, and provides a condition that determines the selection of the partition it begins. The executable content following the <elseif> will be executed if the <elseif>'s "cond" evaluates to true and all preceding "cond"s evaluate to false.
Name | Required | Attribute Constraints | Type | Default Value | Valid Values | Description |
---|---|---|---|---|---|---|
cond | true | Conditional expression | none | A valid conditional expression | An boolean expression. See 8.1 Conditional Expressions for details. |
<log> allows an application to generate a logging or debug message which a developer can use to help in application development or post-execution analysis of application performance. The manner in which the message is displayed or logged is platform-dependent. The usage of label is platform-dependent. The use of <log> MUST have no other side-effects on interpretation. <log>is an empty element.
Name | Required | Attribute Constraints | Type | Default Value | Valid Values | Description |
---|---|---|---|---|---|---|
label | false | string | none | A character string which may be used to indicate the purpose of the log. | ||
expr | true | Value expression | none | An expression returning the value to be logged. See 8.3 Legal Data Values and Value Expressions for details. The nature of the logging mechanism is implementation-dependent, so the platform may convert this value to a convenient format before logging it. | ||
level | false | positiveInteger | 1 | This information will be logged only if the system's log level is at this level or higher. The mechanism for specifying the log level and its legal values will be specified in a future version of this document. |
The content presented in this specification represents a flexible, powerful, minimum set that all applications can rely on. Platforms are free to provide additional executable content corresponding to special features of their implementations. The functionality of such platform-specific content is not restricted, except that it may not cause transitions or any form of change of state, except indirectly, by raising events that are then caught by transitions. It is important to remember that SCXML treats executable content as a single blocking atomic operation and that no events are processed until all executable content has completed. For example, upon entering a state, the SCXML processor will not process any events or take any transitions until all <onentry> handlers have finished. Thus all executable content, including platform-specific extensions, SHOULD complete quickly under all circumstances. A general method for implementing extensions using the <send> element is presented in E.4 Custom Action Elements below.
Platform-specific extensions to executable content SHOULD be defined in a separate namespace, not in the 'scxml' namespace. Note that the schema D Schemas allows elements from arbitrary namespaces inside blocks of executable content. The following example shows the incorporation of CCXML functionality (see [W3C CCXML 1.0] ) into SCXML. In particular an <accept> element in the 'ccxml' namespace is invoked as executable content inside a transition.
<transition event="ccxml:connection.alerting"> <ccxml:accept connectionid="eventdata.connectionid"/> </transition>
This markup is legal on any SCXML interpreter, but the interpretation of the <accept> element is platform-dependent. Platforms that do not support the element will either ignore it or signal an error, depending on the value of the 'exmode' attribute on the <scxml> element (see 3.1.1 Attribute Details ).
The "src" attribute on <state> and <parallel>
contains a URL which is used to reference an external file
containing all or part of the definition of the state. The file
must contain a document that matches the SCXML schema but it need
not match the extra-schematic constraints contained in this
specification. (For example, the document may contain transitions
that reference state IDs ids that are not defined within it.) The exact
treatment of the file depends on the format of the URL. If it ends
with '#' followed by a string, the string is taken to be the
ID id of an
element in the file and the children of that element are
inserted into the state's definition before any other
material contained in the <state>. Thus the state is
incorporating the definition of a state defined within the file.
If, on the other hand, the URL does not contain '#', the contents
of the <scxml> element are inserted into the definition of
the state before any other material in the state, along
with an <initial> element whose <transition> takes as
its target the value of the <scxml> element's 'initial'
attribute. Thus in this case the contents of the entire state
machine are inserted into the definition definiiton
of the state.
Suppose that the file at "someURL" looks as follows:
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initialstate="someState"><scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initial="someState"> <state id="someState"> <transition event="foo" target="someOtherState"/> </state> <state id="someOtherState"> <transition event="bar" target="finalState"/> </state> </scxml>
A 'src' expression referencing 'someOtherState' will result in 'someOtherState's contents being inserted into the state's definition, as shown below. The following markup:
<state id="state1" src="someURL#someOtherState"> <transition event="state1.Done" target="yetAnotherState"/> <final id="finalState"/> </state>
will expand to:
<state id="state1"> <transition event="bar" target="finalState"/> <transition event="state1.Done" target="yetOtherState"/> <final id="finalState"/> </state>
On the other hand, a 'src' expression referencing the whole file will result in both 'someState' and 'someOther' state being inserted into the state's definition, along with the appropriate <initial> element. Thus
<state id="state1" src="someURL"> <transition event="state1.Done" target="yetOtherState"/> <final id="finalState"/> </state>
becomes
<state id="state1"> <initial> <transition target="someState"/> </initial> <state id="someState"> <transition event="foo" target="someOtherState"/> </state> <state id="someOtherState"> <transition event="bar" target="finalState"/> </state> <transition event="state1.Done" target="yetOtherState"/> <final id="finalState"/> </state>
File inclusion takes place at load time. Implementations are free to perform document validation by any method they choose as long as the result is logically equivalent to a single pass of validation occurring after the material from the external file has been incorporated. (Note that implementations are not required to validate the external file. All that is required is that the document resulting from the incorporation be valid.)
The SCXML schema D.7 Minimal Profile Schema requires that the ids of <state>, <parallel>, and <final>, as well as <history>, be unique within the document. Therefore an included file MUST not contain ids which conflict with those in the including file or in another included file. If such a conflict occurs, the document will fail schema validation. It is the script author's responsiblity to avoid these problems. One obvious way to do this is to generate/rewrite the included file dynamically adding a prefix to each ID and IDRef in it.
Events are one of the basic concepts in SCXML since they drive most transitions. The internal structure of events is platform-specific as long as the following external interface is observed:
There is a class of error events whose names begin with
'error.'. They may be raised by the platform, as specified in this
document, or under application control. They are placed in the
internal event queue and processed like any other event. In
particular, they are not processed immediately if there are other
events in the queueand queue and they are ignored if no transition is
found that matches them. Note however that authors can arrange for
otherwise unhandled errors to cause the interpreter to exit by
creating a transition with "event" attribute of 'error.*' 'error' and
a target of any top-level final state (i.e. one that is a child of
<scxml>). If such a transition T is placed in a state S, it
will cause the state machine to terminate on any error that is
raised in S or one of its substates and is not handled by another
transition that is placed in a substate of S or in S and preceding
T in document order.
In many applications, it is important for SCXML to receive events from external entities (for example those which it contacted with <invoke> and <send>.) Such applications should use profiles that include 4 External Communications Module .
For the most part, the set of events raised during the execution
of an SCXML document is application-specific and generated under
author control by use of the <event> <raise> and <send> elements. However,
certain events are mandatory and generated automatically by the
interpreter. In this version of the specification, in addition to
error events, there is only the 'Cancel' done.state.
stateid event which is sent if the state machine leaves the containing
state after executing the <invoke> element but before
receiving and the 'Done' done.invoke.
stateid.platformid event.
Note that there are also mandatory events
that invoked components must return to the invoking SCXML state
machine. In this version of the specification, there are two such
events, namely 'Done' and 'CancelResponse'. We may well
change or expand this set of mandatory events in future drafts of
this specification. Furthermore, it is likely that there will be
distinct profiles of SCXML for specific applications, such as the
Multi-modal Interaction Framework [W3C MMI] and
VoiceXML 3.0. These profiles will define extensions to the core
language and will likely extend the set of mandatory events with
additional events appropriate to the specific application.
Platforms may extend the names of these automatically generated events if they desire. For example, a platform could extend done.state. stateid with a timestamp and generate done.state. stateid.timestamp instead. Because any prefix of done.state. stateid is also a prefix of done.state. stateid.timestamp ,any transition that matches the former event will also match the latter.
[N.B. In a future draft, the contents of
this section will be updated to deal with the fact that different
profiles may use different data models or possibly no data model at
all.] The External Communications Module adds the capability
of sending and receiving events from external entities, as well as
invoking external services. Its schema can be found at D.3 Schema for External
Module .
Profiles that include the External Communications module
MUST: MUST :
<send> is used to send events and data to external
systems, including external SCXML Interpreters, or to raise
external events in the current SCXML
session.
The target of <send> is specified using the "target" and
"targettype" "type" attributes. These attributes control how
the platform should dispatch the event to its final
destination.
The "target" attribute specifies the unique identifier of the
event target that the system should send the event to. This can be
the session ID identifier of another SCXML session. In other
cases the value of this attribute will depend on the type of the
target. (For example a SIP URL for SIP-INFO messages or a HTTP URL
for Web Services). If no "target"
attribute the target is
specified the default special term
'_internal', the event will be added to the internal event queue of
the sending session. If no target attribute is specified, the current
SCXML event will be added to the
external event queue of the sending session. If the value
of the "target" attribute is not supported, invalid or unreachable
by the platform, the system will raise an
error.send.targetunavailable event.
The "targettype" "type" attribute describes the type of the event
target and is used in conjunction with the "target" attribute to
determine how to connect to the target. The default value of this
attribute is 'scxml'. If the event "targettype" "type"
specified is not supported, the platform will raise an error.send.targettypeinvalid event. the error event error.send.typeinvalid.
A platform must support the following value for the "targettype" "type"
attribute:
Value | Details |
---|---|
"scxml" | Target is an SCXML session. The transport mechanism is platform-specific. |
The SCXML Event Processor is described in G SCXML Event I/O Processor .
Support for HTTP POST is optional, however platforms that
support it must use the following value for the
"targettype" "type" attribute:
Value | Details |
---|---|
"basichttp" | Target is a URL. Data is sent via HTTP POST |
The basic HTTP Event Processor is
described in H Basic HTTP
Event I/O Processor . Platforms may support other
types of Event I/O Processors, for example: Web-services, SIP or
basic HTTP GET. However, platforms SHOULD name the
targettype type beginning with "x-" to signify that they are
platform dependent.
Note that <event> is used to raise
internal events in the current SCXML session. Thus both
<send> and <event> may be used to raise events in the
current session, the only difference being whether the event is
added to the session's internal event queue or external event
queue. This difference may produce subtle differences in timing
between the two methods since external events are processed only
when the internal event queue is empty. See B Algorithm for SCXML
Interpretation for details. <send> also specifies the
content of the message to be sent. <send> may specify message
the message name via the optional "event"
attribute. Additional content may be
specified in one of the two
three following mutually exclusive
ways:
<datamodel><data ID="target" expr="'tel:+18005551212'"/> <data ID="content" expr="'http://www.example.com/mycontent.txt'"/><data id="target" expr="'tel:+18005551212'"/> <data id="content" expr="'http://www.example.com/mycontent.txt'"/> </datamodel> ...<send target="target" targettype="'x-messaging'" event="'fax.SEND'" namelist="content"/><send target="target" type="'x-messaging'" event="'fax.SEND'" namelist="content"/>
<send target="'csta://csta-server.example.com/'" targettype="'x-csta'" xmlns:csta="http://www.ecma.ch/standards/ecma-323/csta"><send target="'csta://csta-server.example.com/'" type="'x-csta'"> <content> <csta:MakeCall> <csta:callingDevice>22343</callingDevice> <csta:calledDirectoryNumber>18005551212</csta:calledDirectoryNumber> </csta:MakeCall> </content> </send>
The sending SCXML Interpreter MUST not alter the content of the <send> and must send all the data contained within the message to the destination specified in the target attribute of <send>.
If the "targettype" "type" specified in the <send> is not
supported, the platform will raise an error event send.failed.targettypenotsupported.stateID.sendID,
send.failed.typenotsupported.
stateid.sendid , where
'stateID' stateid is the "id" id of the
<state> containing the <send>, and 'sendID' sendid is the automatically generated
ID id for
this instance of <send>. If no "sendID" send id is
specified in the <send> element, this part of the event name
will be omitted. If the "targettype"
"type" is valid, but the platform is
still unable to send the message for other reasons, the platform
will raise an error event send.failed.targetnotfound.stateID.sendID,
send.failed.targetnotfound.
stateid.sendid , where
'stateID' stateid and 'sendID' sendid have the same significance as in the
targettypenotsupported typenotsupported event. In the case of
<send> elements with a "delay" attribute, these errors will
be raised when the delay interval has passed and the platform
actually attempts to send the event. Note that the absence of any
error events does not mean that the event was successfully
delivered to its target, but only that the platform was able to
dispatch the event.
Name | Required | Attribute Constraints | Type | Default Value | Valid Values | Description |
---|---|---|---|---|---|---|
event | false | This attribute |
Value expression | none | A value expression which returns a character string that
indicates the type of error.fetch event
will be thrown. If used in conjunction with the inline content, an
error.fetch will be thrown. |
|
target | false | Value expression | A valid target URL | A value expression returning a unique identifier of the
|
||
false | Value expression | 'scxml' | A value expression which returns a character string that
specifies the type of the
|
|||
false | This attribute may not occur with 'idlocation'. | NMTOKEN | none | Any valid token | A string literal to be used as the identifier for this instance of <send>. It is the author's responsibility to insure that it is unique. | |
idlocation | false | This attribute may not occur with 'id'. | Location expression | none | Any valid location expression | Any |
delay | false | This attribute may not be used with "target" '_internal'. | Value expression | '0s' | A value expression which returns a time designation as defined in CSS2 [CSS2] format | The character string returned is interpreted as a time
interval. The send tag will return immediately, but
the send are evaluated when the send element is first
processed, and not when the message is actually dispatched.
Timers are useful for a wide variety of programming tasks, and can
be implemented using this attribute. Note: The queue
for |
false | This attribute may not be specified in conjunction with
|
List of location expressions | none | List of data model locations | A space-separated list of zero or
more data model locations to be included with the |
|
hints | false | Value expression | none | A value expression. | The data returned contains information which may be used by the implementing platform to optimize message transmission. The meaning of these hints is platform-specific. |
"namelist" and <content> may not co-occur. That is, the developer may specify the content of the event either with the "namelist" element and/or 1 or more occurrences of the <param> element, or with a single occurrence of the <content> element, but not both.
The <cancel> element may be used to cancel a delayed <send> event. The system will attempt to cancel the pending event and will raise an internal event cancel.successful if it succeeds. Otherwise it will raise an error.notallowed event. <cancel> may be used to cancel only events that were raised by a <send> occurring in the same document.
<invoke> and its child <finalize> are useful in
states that model the behavior of an external service. The
<invoke> element is executed immediately after the state's <onentry>
element and sends causes an event
invoking instance of the external
service. service
to be created. The <param> element may be used to pass
data to the service. Any events that are received by the state
machine from the invoked component during the invocation are
preprocessed by the <finalize> handler before
transitions are selected. The <finalize> code is used to
normalize the form of the returned data and to update the data
model before the transitions' "event" and "cond" clauses are
evaluated.
When the <invoke> element is executed, the platform
MUST start
a new logical instance of the external service specified in
"targettype" "type" and pass it the data specified by "src",
"srcexpr", <content>, or
<param>. The service instance MAY be local or
remote. In addition to the explicit arguments, the platform
MUST
pass a unique id to the external service .
The external service MUST include keep track of the same
unique invoke id and insure that it is included in all events that
it the invoked
service returns to the invoking machine. (Syntax TBD.)
The external service MAY generate multiple events while it is processing,
but it MUST generate a special ''id.Done' event , (where
the 'id' is the id for this invocation) 'done.invoke. invokeid ' once
it has finished processing. It
processing, where invokeid is the
identifier for the corresponding <invoke> element. The
external service MUST not generate any other events afterwards. after this done
event. If the invoking state machine takes a transition out
of the state containing the <invoke> before it receives the
'Done' 'done.invoke. stateid.platformid ' event, it MUST automatically send
a 'Cancel' event to cancel the
invoked component to notify it that it
may and stop its processing. The
'Cancel' event will be sent cancel operation MUST act as if it
were the final <onexit> handler in the invoking state.
The invoked component MUST respond to the
'Cancel' event with a 'CancelResponse' event (syntax of both events
TBD). The invoking state machine will take its transition without
waiting for the CancelResponse event, which will be processed like
any other external event. Note that the <invoke> element can
be used to invoke an external SCXML interpreter to execute a
different state machine. In this case, the external state machine
acts in certain respects as if it were a set of substates of the
invoking state. The behavior is thus similar to a complex state
defined with <state> child elements. The most important
difference is that in the <invoke> case, the external state
machine does not share context or event queueswith the invoking
machine. In particular, the invoked machine cannot access any
variables declared in the invoking machine and data can be shared
only by being explicitly passed via the <param> element.
Similarly, events received or generated in one state machine are
not seen by the other, though the two machines may exchange events
via the <send> tag. Furthermore, state IDs need not be
distinct across the two machines (though they must, of course, be
distinct within each machine.) The <invoke> element thus
provides a means of well-encapsulated code reuse.
When parallel states invoke the same external service
concurrently, separate instances of the external service will be
started. They can be distinguished by the
id their invokeids which
is passed with are generated as part of the invocation.
Similarly, the invoke id contained in
the events returned from the external services can be used to
determine which events are responses to which invocation. Each
event that is returned will be processed only by the
<finalize> in the state that invoked it, but that event is
then processed like any other event that the state machine
receives. The finalize code can thus be thought of as a
preprocessing stage that applies before the event is added to the
event queue. Note that the event will be passed to all parallel
states simultaneously to check for
transitions.
<invoke> occurs only in atomic states, namely those that do not have <state> or <parallel> children. Thus, a state may have either <state> and <parallel> children or an <invoke> child,but not both.
Since an invocation will be canceled when the state machine leaves the invoking state, it does not make sense to start an invocation in a state that will be exited immediately. Therefore the <invoke> element is executed upon entry into the state, but only after checking for eventless transitions and transitions driven by pending internal events. If any such enabled transition is found , it is taken and the state is exited immediately, without triggering the invocation. Thus invocations are triggered only when the state machine has reached a stable configuration, i.e., one that it will be staying in while it waits for internal or external events. (See B Algorithm for SCXML Interpretation for details.)
Name | Required | Attribute Constraints | Type | Default Value | Valid Values | Description |
---|---|---|---|---|---|---|
NMTOKEN | 'scxml' | 'scxml', |
A string specifying the type of the external service. Platforms MUST support 'scxml' as a value. Platforms MAY support 'vxml2', which indicates a VoiceXML 2.x interpreter, 'vxml3' which indicates a VoiceXML 3.x interpreter, and 'ccxml', which indicates a CCXML 1.0 interpreter. Platforms MAY support additional values, but they SHOULD name the values beginning with "x-" to signify that they are platform dependent. | |||
src | false | Any expression evaluating to a
valid |
A |
|||
false | This attribute may not occur with 'idlocation' | Any |
A |
|||
idlocation | false | This attribute may not occur with 'id' | Location expression | none | Any valid location expression | Any data model expression
evaluating to |
autoforward | false | boolean | false | true or false | If 'true', any external events received by the state machine will be forwarded automatically to the invoked external service. |
Note that either the "id" or "idlocation" attribute may be specified, but not both. If the author does not provide an explicit identifier via the "id" attribute, the system will generate one automatically. It will store this identifier in the location specified by "idlocation" if that attribute is present. In the rest of this document, we will refer to this identifier as the "invokeid", regardless of whether it is specified by the author or generated by the platform.
At most one of "src" and "srcexpr"
"src", <param>, and
<content>may be specified. However
<param> may occur multiple times if it occurs.
<invoke> MUST not be a sibling of the <state> or <parallel> elements. It thus occurs only in atomic states, namely those which do not have substates.
The invoked external resource is logically
separate from the state machine that invokes it and does not share
data with it unless the author explicitly requests this with the
<param> tag, the <content> tag, the <send> tag or
the 'autoforward' attribute. The <param> tag Data model expression none
Valid 5.5
<param> can be used to
pass a copy of all or part of the state machine's data model
path expression The name to the invoked service. If the 'autoforward' attribute
is set to 'true', the invoking state machine will automatically
forward a copy of all external events
it receives to the parameter. It
external service. The invoking machine
will be passed unmodified send such events at the same time as it pulls them off
the external event queue to process
them. Once it has forwarded the copy, the invoking state machine
will process the event normally, regardless of how it is handled
in the external service. It need not
specify a node
To send messages to the child process on
an ad-hoc basis, SCXML scripts can use the <send> tag. The
type should be set to the same value as was used in the
surrounding original <invoke>, while the target should have
the special form #_ invokeid ,where
invokeid is the identifier corresponding to the original
<invoke> tag. For example, in a profile using ECMAScript as
the data model. expr false
model, the following code would invoke a VXML
session:
<invoke type="vxml" idlocation="_data.myInvoke"/>
In this case, the unique invoke identifier
has been stored in the data model location _data.MyInvoke. Since the target attribute is
an expression An optional value
expression (see which is evaluated, the
following code will extract that identifier and send a message to
the invoked VXML session:
<send type="vxml" target="'#' + _data.myInvoke"/>
Finally, in the case where the invoked
external service is an SCXML session, it may use <send> with
the special target '_parent' and Value
Expressions type 'scxml' to send
events, possibly containing data, to the invoking state
machine.
The implementation of <invoke>, including communication between parent and child processes, is platform-specific, but the following requirements hold in the case where the invoked process is itself an SCXML session:
<finalize>'s children consist of executable content. The
content will be invoked on any event that the external service
returns after <invoke> has been executed. This executable content will be applied
before the system looks for transitions that match the
event. In the case of parallel states, only the finalize code
in the original invoking state will be executed executed.
Within the executable content, the special variable 'event' '_event' may
be used to refer to the data contained in the event which is being
finalized.
If no executable content is specified, a default canonicalization handler will be invoked which will update the data model with any return values corresponding to <param> elements with missing "expr" attributes. Thus the effect of a <param> element with an empty "expr" attribute coupled with an empty <finalize> element is first to send all or part of the data model to the invoked component and then to update that part of the state machine's data model with the returned values. Note that the automatic update does not take place if the <finalize> element is absent as opposed to empty.
The purpose of the executable content is to normalize the format
of data and update the data model before transitions are selected.
<finalize> code may only massage data. It may MUST not raise events or
invoke external actions. 4.5 <content>
4.5.1 Attribute Details None. 4.5.2 Children The child elements of
<content> consist of arbitrary markup which will be passed
unmodified to In particular, the
invoked service. The markup <send> and <raise> elements may
consist of text, XML from any namespace, or a
mixture of both. not occur.
The Data Module offers the capability of storing, reading, and modifying a set of data that is internal to the state machine. Its schema may be found at D.4 Schema for Data Module . As an authoring convenience, the Data Module can read in data from an external source at load time, but at run time it is restricted to operating on its internal model. Note, however, that 4 External Communications Module allows SCXML to interact with external entities at run time, to exchange data as part of the interaction.
Profiles that include the Data Module MUST: MUST :
For examples of how to do this, see 9.2 The ECMAScript Profile and 9.3 The XPath Profile .
To provide a uniform method of access to both local and remote data, we introduce a <datamodel> element which encapsulates any number of <data> elements. Each such element defines a single data object. The exact nature of the data object depends on the data model language used. The data object may be fetched from an external source or specified in-line. In cases where the data object specified is not a legal instance of the data model language, implementations MAY translate it into a legal expression, and MUST signal an error if the cannot do so.
Data created via the <data> element is local to the SCXML interpreter and not shared with any external resource. However, the local data model, or parts of it, may be sent to an external resource via the <send> element. (See 4.1 <send> .) Existing data values may be modified with the <assign> element. (See 5.3 <assign> ).
Logically, there is a single globally visible data model for the entire state machine. As an authoring convenience, however, we allow <datamodel> as a child of any <state>, thus allowing parts of the data model to be distributed throughout the document closer to the locations where the data will be accessed. However, all instances of the <data> element are created and initialized when the state machine is instantiated and may be accessed from any state at any time.
Name | Required | Attribute Constraints | Type | Default Value | Valid Values | Description |
---|---|---|---|---|---|---|
schema | false | URI | none | Location of the schema for this datamodel | URL of the schema for this datamodel. See 5.4 <validate> for its use. This attribute may occur only on the highest-level <datamodel> element, namely the one that is a child of <scxml>. The exact nature of the schema depends on the data model language being used. |
The <data> element is used to declare and populate
portions of the datamodel. All <data> tags are evaluated
exactly once, at load time. Implementations thus MUST evaluate
<data> elements at load time but MAY do so in any
order they choose. Ordering dependencies among <data>
elements are thus not permitted. Suppose, for example, that the
declaration of element "a" precedes
preceeds the declaration of element "b"
in a document. It is not safe to assume that "a" will be
instantiated and have a value when the declaration of "b" is
executed. Therefore the "expr" in "b" cannot reference the value of
"a" (and vice-versa).
Name | Required | Attribute Constraints | Type | Default Value | Valid Values | Description |
---|---|---|---|---|---|---|
true | ID | none | The name of the data item. It MUST be unique within the document. | |||
src | false | URI | none | Any URI referencing a legal data value. See 8.3 Legal Data Values and Value Expressions for details. | Gives the location from which the data object should be downloaded. | |
expr | false | Expression | none | Any valid value expression | Evaluates to provide the value of the data item. See 8.3 Legal Data Values and Value Expressions for details. |
The children of the <data> element represent an in-line specification of the value of the data object.
At most one of "src" and "expr" may occur. If either is present, then the element MUST not have any children. Thus "src", "expr" and children are mutually exclusive inside the <data> element.
In addition to the "src" attribute and in-line child elements, values for the top-level <data> elements can be provided by the environment at instantiation time. The exact mechanism for this is implementation dependent, but values provided at instantiation time override those contained in the <scxml> element, whether they are specified in-line or via the "src" attribute.
If the value specified (by 'src', children, or the environment)
is not a legal data value, the error error.invaliddata is raised at
load time, and an empty data element is created in the data model
with the specified ID. id. Note that what constitutes a legal data value
depends on the data model language used. See 9 Profiles for details.
The <assign> element may be used to modify the data model.
Name | Required | Attribute Constraints | Type | Default Value | Valid Values | Description |
---|---|---|---|---|---|---|
location | true | path expression | none | Any valid location expression. | The location in the data model into which to insert the new value. See 8.2 Location Expressions for details. Note that in the case of an XML data model (see 9.3 The XPath Profile ), it is not required to assign to the root of a tree (i.e., the "name" value in a <data> tag), since the path expression can reach down into the tree to assign a new value to an internal node. | |
false | none | The ID of any <data> element in the document | The 'id' of a <data> element. If it is provided, the
'location' expression is interpreted as applying to the children of
this <data> element. If the |
|||
expr | false | value expression | none | Any valid value expression | An expression returning the value to be assigned. See 8.3 Legal Data Values and Value Expressions for details. If 'expr' is specified, no children are permitted. |
The children of the <assign>element provide an in-line specification of legal data value (see 8.3 Legal Data Values and Value Expressions ) to be inserted into the datamodel at the specified location.
If "expr" is present, then the element MUST not have any children. Thus "expr" and children are mutually exclusive inside the <assign> element.
Assignment to a data model is done by using a location
expression to denote the part of the data model where the change is
to be made. If the location expression does not denote a valid
location in the datamodel an error error.illegalalloc error.illegalloc is raised. If the value specified
(by 'expr' or children) is not a legal value for the location
specified, the error error.invaliddata is raised. Note that what
constitutes a legal value depends on the data model language used.
See 9 Profiles for details.
The <validate> element causes the datamodel to be validated. Note that validation of the datamodel occurs only when explicitly invoked by this element.
Name | Required | Attribute Constraints | Type | Default Value | Valid Values | Description |
---|---|---|---|---|---|---|
location | false | location expression | none | Any valid location expression. | The location of the subtree to validate. If it is not present, the entire datamodel is validated. See 8.2 Location Expressions for details. | |
schema | false | URI | none | Any valid URI | The location of the schema to use for validation. If this attribute is not present, the schema specified in the top-level <datamodel> is used. An error error.validate.validationfailure will be raised at document load time if no schema is specified in either element. |
The <param> tag provides a general way of accessing the data model. It can be used to identify data to be passed to an external service or to be included in an event.
Name | Required | Attribute Constraints | Type | Default Value | Valid Values | Description |
---|---|---|---|---|---|---|
name | true | NMTOKEN | none | A string literal or a valid data model location expression | The name of the parameter. It will be passed unmodified to the external service. It need not specify a node in the surrounding data model. | |
expr | false | value expression | none | Valid value expression | An optional value expression (see 8.3 Legal Data Values and Value Expressions ). If provided, this expression specifies the value to pass to the invoked component. |
If the 'expr' attribute is missing, the 'name' attribute will be taken as a data model location expression (see 8.2 Location Expressions ) and the value at that location will be accessed. If the 'expr' attribute is missing and the 'name' attribute does not refer to a location in the data model, an error error.illegalloc will be generated.
The Data Module maintains a protected portion of the data model containing information that may be useful to applications. We refer to the items in this special part of the data model as 'system variables'. Implementations that include the Data Module MUST provide the following system variables, and MAY support others.
The set of system variables may be expanded in a future version
of this specification. Therefore developers SHOULD NOT use
IDs ids
beginning with '_' in the <data> element since this may cause
forwards-compatibility problems.
The concrete realization of these variables in a specific data model depends on the language used. For the exact location of these variables in an XML data model, see 9.3 The XPath Profile . All system variables are protected and any attempt to change their values MUST fail and result in the error error.illegalassign being raised.
Events have an internal structure which will be reflected in the _event variable. Profiles containing a datamodel can access this structure and use it to condition transitions (via boolean expressions in the 'cond' attribute) or to update the datamodel (via <assign>), etc. It is the responsibility of the SCXML platform that receives the events to fill in these fields appropriately. Platforms SHOULD convert data received from external entities into their local datamodel language if possible. If the conversion is not possible, platforms MAY ignore the event or signal an error.
The following fields are present in all events, whether internal or external.
The following fields are logically present in all events, but will be filled in only in external events:
The Script Module adds scripting capability to the state
machine. Its schema may be found at D.5
Schema for Script Module . Profiles including the Script
Module MUST: MUST :
For an example of how to do this, see 9.2 The ECMAScript Profile .
In profiles that contain both the Script Module and the Data Module, the name of any script variable may be used as a location expression (see 8.2 Location Expressions ).
The <anchor> module is intended to provide 'go back' or 'redo' functionality that is useful in some applications. An anchor MAY be specified instead of a "target" for the transition. In this case, the system transitions to the last state visited containing an <anchor> whose "type" matches the "anchor" specified in the transition.
When a state containing an <anchor> element is entered, a snapshot of the data model is taken before the state's <onentry> handler is executed. The default is to snapshot the entire datamodel, but the application author can restrict the snapshot to part of the datamodel using the 'snapshot' attribute. When a transition is taken with an 'anchor' as its target, the state machine returns to the most recently-visited state with an <anchor> whose 'type' attribute matches the 'anchor' in the transition. In the course of the transition, before the state containing the anchor element is entered, the datamodel is restored from the snapshot. The effect is thus to jump back and restart processing at that state. As part of this restart, all intermediate anchors are erased. Intermediate anchors are those that were set between the time the anchor state was last visited and the point at which the transition with the anchor state as target is taken. Note that all these anchors must have a different type from the one that is the target of the transition. If no state with a matching <anchor> type has been visited, the current state is exited and re- entered. For a complete definition of the semantics of <anchor>, see B Algorithm for SCXML Interpretation . For the schema of the Anchor Module, see D.6 Anchor Module Schema .
The ability to reset the datamodel may lead to accidental, unterminated loops in the state machine. The interpreter context MAY detect these and exit.
Profiles that includ the Anchor Module MUST: MUST :
Name | Required | Attribute Constraints | Type | Default Value | Valid Values | Description |
---|---|---|---|---|---|---|
type | true | xsd:NMTOKEN | none | Defines the type of this anchor instance. | ||
snapshot | false | path expression | none | Any expression denoting a node in the data model. | A location in the datamodel to snapshot. If no snapshot value is provided, the entire data model is copied. Implementations MUST support XPath [XPath] as a path expression language and MAY support other languages if they choose. |
SCXML contains three types of expressions, as described below. Different profiles of SCXML will support different languages for these expression types, but certain properties of the expressions are constant across profiles and are defined here.
Expressions MUST not contain side effects that would effect the datamodel or the execution of the state machine. Implementations MAY assume that expressions do not have side effects when optimizing expression evaluation. Thus expressions may not be evaluated as often as indicated in B Algorithm for SCXML Interpretation or at the same points in the algorithm.
Conditional expressions are used inside the 'cond' attribute of <transition>, <if> and <elseif>. If a conditional expression does not evaluate to a boolean value ('true' or 'false'), the error 'error.illegalcond' is raised. The set of operators in conditional expressions varies depending on the profile, but all profiles must support the 'In()' predicate, which is used to test whether the state machine is in a given state. This predicate allows coordination among parallel regions.
Location expressions are used to specify a location in the
datamodel as part of the <assign>element. The exact nature of
a location depends on the profile. For example, in the XPath
Profile ( 9.3 The XPath Profile
), the underlying datamodel is an XML tree and a location
expression must evaluate to an existing node or nodeset in the
datamodel. If a location expression does not evaluate to a legal
location, an error error.illegalalloc
error.illegalloc is raised.
Any profile that includes the Data Module must specify the structure of the underlying data model. For example, the XPath Profile ( 9.3 The XPath Profile ) defines the data model to be an XML tree. Such a specification of the data model implicitly defines a set of "legal data values", namely the objects that can be part of such a data model. For an XML data model, the set of legal data values consists of XML trees and subtrees, plus strings (as values of attributes or text children). In conjunction with this, the Profile must define a set of value expressions which can be evaluated at runtime to return legal data values. If a value expression does not return a legal data value, the error error.illegalvalue is raised.
Implementations MAY raise errors caused by syntactically ill-formed expressions at document load time, or they MAY wait and raise these errors at runtime when the expressions are evaluated. Implementations MUST raise errors caused by expressions returning illegal values at the points at which B Algorithm for SCXML Interpretation indicates that the expressions are to be evaluated. Note that this requirement holds even if the implementation is optimizing expression evaluation.
A profile defines a concrete realization of the language. Each SCXML document MUST specify the profile it uses. At this point, implementations are required to support only the Minimal profile, which defines the core Harel functionality. Implementations MAY support other profiles, including the ECMAScript and XPath profiles defined below. The ECMAScript and XPath profiles, though optional, are normative in the sense that they define how implementations that support one of these languages MUST behave. The intent is to insure interoperability among all processors that support ECMAScript, and all those that support XPath, without requiring all implementations to support either of those data model languages.
To define a profile, you must first specify the list of modules that the profile includes. This list MUST include the Core module and MAY include other ones. In addition to this list you must:
The Minimal profile defines a stripped down state machine with no external communications or data model, but with full Harel semantics. Conformant SCXML processors must implement the following modules:
SCXML core module: see 3 Core Module
For the schema of theMinimal profile, see D.7 Minimal Profile Schema .
No elements or attributes are extended or redefined. For the schema of the Minimal Profile, see D.7 Minimal Profile Schema .
This section contains information which is specific to the SCXML
ECMAScript profile. In particular, it defines the semantics of
using ECMAScript in binding expressions for data model access,
conditional evaluation, and value expressions in SCXML. It also
defines use of the <script>
element in this
profile.
Conformant SCXML processors must
MUST implement the following modules from
SCXML:
Conformant documents must MUST specify a value of
profile="ecmascript"
on the root
<scxml>
element.
In addition, conformant implementations of the ECMAScript
Profile for SCXML 1.0 must MUST support ECMAScript Compact Profile
[ECMASCRIPT-327] , a strict subset of
the third edition of ECMAScript [ECMASCRIPT-262] . A conformant implementation
may MAY support
ECMAScript for XML (E4X) [E4X] .
Editorial note | |
A later version of this specification will clarify how XML data can accessed, manipulated and generated using this profile. Apart from E4X, we are also considering DOM access functions and ECMAScript 4.0 (4th edition of ECMAScript 262). ECMAScript 4.0 is still under development. The specifications are not yet public. An overview has been published. Many elements of the new language will be familiar to Action Script developers. There are early implementation from Mozilla and on ecmascript.org . |
ECMAScript expressions used in conditional expressions are converted into their effective boolean value using the ToBoolean operator as described in Section 9.2 of [ECMASCRIPT-262] . The expression is evaluated in its own local scope, and allows (read only) access to variables and functions in the global scope, including the data model (see 9.2.3 Data Module Requirements for scoping model).
The following example illustrates this usage.
<state id="errorSwitch"> <datamodel><data ID="time"/><data id="time"/> </datamodel> <onentry> <assign location="_data.time" expr="currentDateTime()"/> </onentry> <transition cond="yearFromDatetime(_data.time) > 2009" target="newBehavior"/> <transition target="currentBehavior"/> </state>
Any errors which arise during the processing of a conditional
expression must SHOULD be mapped into an SCXML
error.illegalcond.
errortype event where the
optional errortype indicates the ECMAScript error type as
specified in Section 15.11.6 of [ECMASCRIPT-262] . For instance, an ECMAScript
expression which attempts to assign a value to a variable defined
in the global scope would generate an
error.illegalcond
event.
Conditional expressions may take advantage of the
In()
predicate. Additional detail appears in 9.2.5.1 The In() predicate .
The underlying data model is the subset of the ECMAScript object model as defined by JSON [RFC4627] . SCXML data model expressions are evaluated as ECMAScript expressions in global or local scope as described later in this section.
The SCXML datamodel is implemented as an ECMAScript object with
the name _data
.
In a <datamodel>
element, each
<data>
child is bound to a property of the
_data
object. The property name is the value of the
attribute of ID id<data>
.
The value of the property is assigned by the evaluation one of the
following expressions:
expr
attributesrc
attribute. JSON resources have the mime type
application/json
.If no value is assigned, the property has the default value ECMAScript undefined.
Evaluation of JSON expressions must
MUST be supported and evaluation of XML
expressions may MAY be supported.
The _data
object must
MUST be created by the processor upon
initialization of the SCXML document. Any errors which arise during
initialization must SHOULD be mapped into an SCXML
error.illegaldata
.errortype event where the
optional errortype indicates an ECMAScript error type as
specified in Section 15.11.6 of [ECMASCRIPT-262] . For example, an error will
be raised if the <data>
element's
attribute is not a valid ECMAScript
variable name or if the evaluation of the ID idexpr
attribute value fails.
<scxml version="1.0" profile="ecmascript"> <datamodel><data ID="employees" src="http://example.com/employees.json"/> <data ID="year" expr="2008"/> <data ID="CEO" expr="\"Mr Big\""/> <data ID="profitable" expr="true"/><data id="employees" src="http://example.com/employees.json"/> <data id="year" expr="2008"/> <data id="CEO" expr="\"Mr Big\""/> <data id="profitable" expr="true"/> </datamodel> </scxml>
This profile uses ECMAScript scoping. Elements in the SCXML document are associated with ECMAScript scopes which themselves are chained together. Scopes are created when the SCXML processor enters specific elements, and the scope is destroyed when processor exits the element. This profiles defines two ECMAScript scopes: global and local.
A global scope must MUST be defined for each SCXML session. The
global scope is created when the SCXML session is created. The
SCXML datamodel is contained within the global scope. The global
scope has no parent scope.
The SCXML elements <state>
,
<parallel>
, <final>
and
<transition>
, as well as cond
attributes, are each associated with an ECMAScript local scope. The
local scope always has the global scope as its parent.
Consequently, variables and function prototypes in the global scope
are accessible through this scope chain.
Variable bindings take place in the local scope except for
bindings to the variables defined in the global scope.
Consequently, bindings to the datamodel ( _data
object) are applied at global scope.
References to variables in the global and local scopes can be
disambiguated by explicit scope designation: prepending the scope
name plus "." to the variable name. For example,
global.time
identifies a variable with the name
time
in global scope, while local.time
identifies a variable the same name in local scope. A variable
reference without an explicit scope designation, references a
variable in the local scope if defined, otherwise references a
variable in the global scope.
Variables bindings are defined for the lifecycle of the respective scope.
Editorial note | |
We solicit feedback on whether only two scopes, local and global, are sufficient for applications. |
ECMAScript left-hand-side expressions are used to select an object (or sub-property of an object) from the data model by providing a binding expression. The following example illustrates this usage:
<state id="errorSwitch"> <datamodel><data ID="employees" src="http://example.com/employees.json"/><data id="employees" src="http://example.com/employees.json"/> </datamodel> <onentry> <assign location="_data.employees.employee[12].salary" expr="42000"/> </onentry> </state>
Any errors which arise during the processing of a location
expression must SHOULD be mapped into an SCXML
error.illegalalloc.
errortype event where the
optional errortype indicates the ECMAScript error type as
specified in Section 15.11.6 of [ECMASCRIPT-262] . For example, an error will
arise if there is an attempt to assign a value to a system variable
( 9.2.3.3 System
Variables ).
The result of any ECMAScript expression may be used in a value expression.
<state id="processEvent"> <datamodel><data ID="myEvent"/><data id="myEvent"/> </datamodel> <onentry><assign location="_data.myEvent" expr="_data._event"/><assign location="_data.myEvent" expr="_event.data"/> </onentry> </state>
Any errors which arise during the processing of a value
expression must SHOULD be mapped into an SCXML
error.illegalvalue.
errortype event where the
optional errortype indicates the ECMAScript error type as
specified in Section 15.11.6 of [ECMASCRIPT-262] .
System variables are defined as ECMAScript read-only variables
in global scope. The _event
system variable is defined
as an object with two properties: name
(String value)
for the name of the event; and data
(Object value)
exposing the event data payload. The
and _sessionID _sessionid_name
system
variables are defined as variables with ECMAScript String
values.
The
and _event value must be assigned by
processor before triggering executable content in the
<onentry>, <onexit>, and <transition> elements
which may reference the variable. The processor must clear the
value by setting _event to ECMAScript undefined values when event
processing has completed. The _sessionID _sessionid_name
values
must MUST be set by the processor at session
start.
Editorial note | |
This section is tentative and subject to revision in a later version of this specification. |
In this profile, the inline content of the
<script>
is an ECMAScript program as defined in
Section 14 of [ECMASCRIPT-262] .
This profile allows <script>
elements to
occur as children of <scxml>
elements and within
executable content.
When a <script>
element is a child of
<scxml>
its contents are evaluated in global
scope at document load time. Defined variables and functions are
available through the scope chain to expressions in local
scope.
When a <script>
element occurs within
executable content it is evaluated in the local scope associated
with the containing element (or its ancestor).
Any errors which arise during processing of
<script>
content must SHOULD be mapped into an
SCXML error.script.
errortype event where the
optional errortype indicates the ECMAScript error type as
specified in Section 15.11.6 of [ECMASCRIPT-262] .
<scxml version="1.0" profile="ecmascript"> <script> var globalCounter = 0; function updateCounter() { globalCounter++; } </script> </scxml>
<state id="updateDM"> <onentry> <script> _data.myDate = new Date(); updateCounter(); </script> </onentry> </state>
Editorial note | |
A later version will clarify how inline ECMAScript interacts with fetched ECMAScript programs (where external fetching takes place at document initialization, evaluation when the element is executed). |
A conformant SCXML processor must
MUST add an ECMAScript function to the SCXML
namespace that implements the In()
semantics described
in section 8.1 of the [SCXML1] specification.
Function signature:
Returns an In($arg as
xs:string?) as xs:boolean function
In(arg) { }xs:boolean ecmascript
value indicating whether or not one of the current active
states has an id that matches the value
of $arg . $arg.
This value will be converted to boolean using the ToBoolean
operator.
This specification contains information which is specific to the SCXML XPath profile. In particular, it defines the semantics of using XPath in binding expressions for data model access, conditional evaluation, and value expressions in SCXML.
Conformant SCXML processors must implement the following modules from SCXML
Conformant documents must specify a value of
profile="xpath"
on the root <scxml>
element.
In addition, conformant implementations of the XPath Profile for
SCXML 1.0 must MUST support [XPath
2.0] .
For the schema of the XPath profile, see D.9 XPath Profile Schema .
XPath 2.0 expressions used in conditional expressions are converted into their effective boolean value as described in section 2.4.3 of the [XPath 2.0] specification. The following example illustrates this usage.
<state id="errorSwitch" xmlns:fn="http://www.w3.org/2005/xpath-functions"> <datamodel><data ID="time"/><data id="time"/> </datamodel> <onentry><assign location="instance('time')" expr="fn:current-dateTime()"/><assign location="$time" expr="fn:current-dateTime()"/> </onentry><transition cond="fn:year-from-dateTime(/data[@ID='time']) > 2009" target="newBehavior"/><transition cond="fn:year-from-dateTime($time) > 2009" target="newBehavior"/> <transition target="currentBehavior"/> </state>
Any errors which arise during the processing of a conditional
expression must SHOULD be mapped into an SCXML
error.illegalcond.
errorcode event where the
errorcode is the value specified in [XPath 2.0] and related specifications such as the
[XPath 2.0 Functions and Operators] . For
instance, an XPath expression which attempts to use a component
having an undefined value would generate an
error.illegalcond.XPST0001
event.
Conditional expressions may take advantage of the
predicate. Additional detail
appears in 9.3.4.1 The In() scxml:In()In() scxml:In()
predicate .
XPath 2.0 expressions are used to select a node-set from the data model by providing a binding expression. The following example illustrates this usage:
<state id="errorSwitch"><datamodel> <data ID="cities"> <city id="nyc" count="0">New York</city> <city id="bos" count="0">Boston</city> </data> </datamodel> <onentry> <assign location="instance('cities')/city/@count" expr="1"/> </onentry><datamodel> <data id="cities"> <list xmlns=""> <city id="nyc" count="0">New York</city> <city id="bos" count="0">Boston</city> </list> </data> </datamodel> <onentry> <assign location="$cities/list/city[id='nyc']/@count" expr="1"/> </onentry> </state>
Any errors which arise during the processing of a location
expression must SHOULD be mapped into an SCXML
error.illegalalloc.
errorcode event where the
errorcode is the value specified in [XPath 2.0] and related specifications such as the
[XPath 2.0 Functions and Operators] .
The result of any XPath expression may be used in a value expression. If the result of the value expression is a node-set, a deep copy of the subtree rooted at each node is made.
<state id="processEvent"><datamodel> <data ID="myEventData"/> </datamodel><datamodel> <data id="myEventData"/> </datamodel><onentry> <assign location="instance('myEventData')" expr="/data[@ID='_event']"/> </onentry><onentry> <assign location="$myEventData" expr="$_event/data"/> </onentry> </state>
Any errors which arise during the processing of a value
expression must SHOULD be mapped into an SCXML
error.illegalvalue.
errorcode event where the
errorcode is the value specified in [XPath 2.0] and related specifications such as the
[XPath 2.0 Functions and Operators] .
Within the Data Model, three implicit <data> elements are
defined to hold the system variables as described in section 5.6 of
the [XPath 2.0] specification. These are
named
, _event $_event
, and _sessionID $_sessionid
._name $_name
The
value _event $_eventmust MUST be assigned by
processor before triggering executable content in the
<onentry>, <onexit>, and <transition> elements
which may reference the variable. The processor must MUST clear the value by
setting its child elements <name> and <data> to empty
XML elements when event processing has completed.
The
and _sessionID $_sessionid
values _name $_namemust MUST be set by the processor at session
start.
The following SCXML shows
illustrates the structure of the system
variables in the XPath profile.
<scxml name="myName" profile="xpath" ...><datamodel> <data ID="_name">mySCXMLMachine</data> <data ID="_sessionID">12343</data> <data ID="_event"> <name/> <data/> </data> </datamodel> ...<datamodel> <data id="_name">mySCXMLMachine</data> <data id="_sessionid">12343</data> <data id="_event"> <name/> <data/> </data> </datamodel> ... </scxml>
Here is an example of accessing the
variable in a transition._sessionID $_sessionid
<state id="checkSessionID"> <transition cond="/data[@ID='_sessionID'] = '12343'" target="nextState"/> ...<state id="checkSessionid"> <transition cond="$_sessionid = '12343'" target="nextState"/> ... </state>
A conformant SCXML processor must
MUST add an XPath function to the SCXML
namespace that implements the In()
semantics described
in section 8.1 of the [SCXML1] specification.
Function signature: In($arg as xs:string?) as
xs:boolean
Returns an xs:boolean
indicating whether or not one
of the current active states matches the value of $arg
.
The following examples show various aspects of assignment in the XPath profile. Suppose we have a data model of the following form:
<data ID="cart"> <myCart> <books> <book> <title>The Zen Mind </title> </book> <book> <title>Freakonomics </title> </book> </books> <cds> <cd name="something"/> </cds> </myCart><data id="cart"> <myCart xmlns=""> <books> <book> <title>The Zen Mind</title> </book> <book> <title>Freakonomics</title> </book> </books> <cds> <cd name="Something"/> </cds> </myCart> </data>
Here is an example of assignment of a string to an element node.
<assign location="instance('cart')/myCart/books/book[0]/title" expr="'My favorite book'"/><assign location="$cart/myCart/books/book[0]/title" expr="'My favorite book'"/>
results in
<data ID="cart"> <myCart> <books> <book> <title>My favorite book </title> </book> <book>> <title>Freakonomics </title> </book> ...<data id="cart"> <myCart xmlns=""> <books> <book> <title>My favorite book</title> </book> <book> <title>Freakonomics</title> </book> ... </data>
Now suppose we assign an xml structure to an element node. The
following assignment statement would have the effect of replacing
the children of the element "/data[@ID='cart']/myCart/books/book[0]"
"$cart/myCart/books/book[0]" by the XML
tree rooted in <bookinfo>.
<assign location="instance('cart')/myCart/books/book[0]"> <bookinfo> <isdn>12334455</isdn> <author>some author</author><assign location="$cart/myCart/books/book[0]"> <bookinfo xmlns=""> <isdn>12334455</isdn> <author>some author</author> </bookinfo> </assign>
results in
<data ID="cart"> <myCart> <books> <book> <bookinfo> <isdn>12334455</isdn> <author>some author</author> </bookinfo> </book> <book>> <title>Freakonomics </title> </book> ...<data id="cart"> <myCart xmlns=""> <books> <book> <bookinfo> <isdn>12334455</isdn> <author>some author</author> </bookinfo> </book> <book> <title>Freakonomics</title> </book> ... </data>
Here are examples of legal and illegal assignment to an attribute:
<!-- Legal assignment: --><assign location="instance('cart')/myCart/cds/cd/@name" expr"'Something Else'"/><assign location="$cart/myCart/cds/cd/@name" expr"'Something Else'"/> <!-- Illegal assignment: --><assign location="instance('cart')/myCart/cds/cd/@name" ><assign location="$cart/myCart/cds/cd/@name" > <foo><boo><bar/> </foo> </assign>
Now suppose we assign a string to a nodeset. The following
assignment statement would have the effect of replacing the
children of each node in the nodeset /myCart/books/book $cart/myCart/books/book with the string "The Zen
Mind":
<assign location="instance('cart')/myCart/books/book" expr="'The Zen Mind'"/><assign location="$cart/myCart/books/book" expr="'The Zen Mind'"/>
results in
<data ID="cart"> <myCart> <books> <book>The Zen Mind</book> <book>The Zen Mind</book> </books>> ...<data id="cart"> <myCart xmlns=""> <books> <book>The Zen Mind</book> <book>The Zen Mind</book> </books> ... </data>
Finally suppose we assign a structure to a nodeset. The following statement would iterate over the elements in the nodeset of <book> elements and replace their children with the <price> structure:
<assign location="instance('cart')/myCart/books/book"> <price>20.0</price> </assign><assign location="$cart/myCart/books/book"> <price>20.0</price> </assign>
results in
<data ID="cart"> <myCart> <books> <book> <price>20.0</price> </book> <book>> <price>20.0</price> </book> </books> ...<data id="cart"> <myCart xmlns=""> <books> <book> <price>20.0</price> </book> <book> <price>20.0</price> </book> </books> ... </data>
If the evaluation of any of the expressions in an <assign>
element causes an error to be raised, evaluation of the element
terminates immediately and the <assign> has no effect. For
example, the following assignment statement would raise an error
because the sample datamodel we are using does not have an
<isbn> <ISBN> node as a child of <book>:
<assign location="instance('cart')/myCart/books/book[0]/ISBN" expr="'....'"/><assign location="$cart/myCart/books/book[0]/ISBN" expr="'....'"/>
A number of other XML-based state machine notations have been developed, but none serves the same purpose as SCXML. XMI [UML XMI] is a notation developed for representing UML diagrams, including Harel State charts. However it is intended as a machine interchange format and is not readily authorable by humans. ebXML [OASIS ebXML] is a language for business process specification intended to support B2B e-commerce applications. It contains a state machine language that is in some ways similar to the one presented here, but its syntax and semantics are closely tied to its intended use in e-commerce. It is therefore not suitable as a general-purpose state machine language. XTND [XTND] , also called XML Transition Network Definition, is a notation for simple finite state machines but lacks Harel's notions of hierarchical and parallel states and are thus not suitable for a general-purpose state machine that is semantically equivalent to Harel statecharts.
Issue ():
We need are
considering adding an iterative construct, such as 'foreach' or
'while', to define a set of I/O
processors for the External
Communications Module and specify executable content in the interactions between them Core module. Such a construct is not strictly necessary,
since iterators can be modeled by conditionalized targetless
transitions. For example, to model a 'while' loop with condition C
and body B, create an eventless transition with condition C and
executable content B. It will keep firing and executing B without leaving its containing state as long
as C is true. However, an explicit iterator might permit more
succinct state machines. We sollicit comments on the
Data Module for different profiles.
usefulness of such a construct.
Resolution:
None recorded.
It could be argued that the current choice of names of SCXML elements and attributes is not optimal. Often rather long words are used (e.g. "transition", "target" and "location"), making lines longer than necessary, and contributing to the size of SCXML documents. Also, abbreviations are used in some cases (e.g. "expr" and "cond") but not in others, which may give the impression of a language not well thought out. Moreover, conventions for how to order the attributes within elements are lacking, which may make SCXML documents harder than necessary to read and understand.
We are considering redesigning this aspect of SCXML. For example, what is now written as follows:
<transition event="e" cond="x>1" target="s"> <assign location="/a/b" expr="2"/> <send event="e" target="t" expr="5" delay="2s"/> </transition>
could instead be written like so:
<go to="s" on="e" if="x>1"> <assign data="2" to="/a/b"/> <send event="e2" data="5" to="t" after="2s"/> </go>
Note that the latter notation (but not so much the former) suggests a very natural translation into English, e.g. as follows:
"go to s on e if x is bigger than one, assign two to /a/b and send e2 with a payload of five to t after 2 seconds" It seems there might be a way to name elements and attributes that 1) avoids abbreviations, 2) yet uses less space, 3) is easier to write, 4) is easier to read (since it is closer to English) and 5) suggests an natural order of attributes within elements, based on how the element reads when it is translated into English.
Would such a change of naming conventions be an improvement?
Could it serve to attract more new users to SCXML? Or would it
break to much with "tradition" and thus repel repell some
current users? We solicit feedback on this matter.
Resolution:
None recorded.
In the case of transitions selected from parallel regions, the
current algorithm completely specifies a) which transition is to be
selected in case of conflicts (see isPreempted? isPreempted in B Algorithm for SCXML
Interpretation ) and b) the order in which those
transitions should be taken (see microstep in B Algorithm for SCXML
Interpretation ). However, we could avoid completely
specifying one or both of these choices. This would give
implementations greater flexibility, but would impair the
portability of applications, which would not necessarily behave the
same way on different platforms. We solicit feedback on these
alternatives.
Resolution:
None recorded.
Issue ():
We need to specify the full set of errors that the platform may raise.
Resolution:
None recorded.
Issue (returndata): ():
Do we need a <returndata>
In the current version of the algorithm,
having an <initial> element separate from <send>? with a transition to a <history> pseudo-state
leads to unexpected results. The default history state is entered,
even if the state has already been visited and there is a
non-default history value.
Resolution:
None recorded.
This section presents a normative algorithm for the interpretation of an SCXML document. Implementations are free to implement SCXML interpreters in any way they choose, but they must behave as if they were using the algorithm defined here.
The fact that SCXML implements a variant of the Statechart formalism does not as such determine a semantics for SCXML. Many different Statechart variants have been proposed, each with its own semantics. This section presents an informal semantics of SCXML documents, as well as a normative algorithm for the interpretation of SCXML documents.
The following definitions and highlevel principles and constraint are intended to provide a background to the normative algorithm, and to serve as a guide for the proper understanding of it.
case
that the parent of s (if any) is also in c. Note,
however, that <scxml> is not a(n explicit) member of the
configuration.case
of parallel states) more transitions, a microstep is taken,
involving the processing of each of the enabled transitions. This
microstep may change the the current configuration, update the
datamodel and/or generate new
(internal and/or
external) events. This, by causality, may in turn enable additional
transitions which will be handled in the next microstep in the
sequence, and so on.We state here some principles and constraints, on the level of semantics, that SCXML adheres to:
This section presents a normative algorithm for the interpretation of SCXML documents. Implementations are free to implement SCXML interpreters in any way they choose, but they must behave as if they were using the algorithm defined here. Note that the algorithm assumes a Lisp-like semantics in which the empty Set null is equivalent to boolean 'false' and all other entities are equivalent to 'true'.
These are the abstract datatypes that are used in the algorithm.
datatype Listfunction
head() // Returns the head of the listfunction
tail() // Returns the tail of the listfunction
append(l) // Returns the list appended with lfilter(f) // Returns the list of elements that satisfy the predicate f some(f) // Returns true if some element in the list satisfies the predicate f every(f) // Returns true if every element in the list satisfies the predicate ffunction
filter(f) // Returns the list of elements that satify the predicate ffunction
some(f) // Returns true if some element in the list satifies the predicate ffunction
every(f) // Returns true if every element in the list satifies the predicate f datatype Setprocedure
add(e) // Adds e to the setprocedure
delete(e) // Deletes e from the setfunction
member(e) // Is e a member of set?function
isEmpty() // Is the set empty?function
toList() // Converts the set to a listfunction
diff(set2) //Returns all members of Set that are not in set2 datatype Queueprocedure
enqueue(e) // Puts e last in the queuefunction
dequeue() // Removes and returns first element in queuefunction
isEmpty() // Is the queue empty? datatype BlockingQueueprocedure
enqueue(e) // Puts e last in the queuefunction
dequeue() // Removes and returns first element in queue, blocks if queue is empty
The following variables are global from the point of view of the
algorithm. Their values will be set in the procedure
interpret()
.
global
datamodel;global
configuration;global
internalQueue;global
externalQueue;global
historyValue;global
continue
This section defines the procedures and functions that make up the core of the SCXML interpreter.
procedure
interpret(scxml,id)The purpose of this procedure is to initialize the interpreter. It is called with a parsed representation of an SCXML document.
In order to interpret an SCXML document, first perform inplace
expansions of states by including SCXML source referenced by
URIs urls
(see 3.11
3.13 Referencing External Files
) and change initial attributes to initial container children with
empty transitions to the state from the attribute. Then
(optionally) validate the resulting SCXML, and throw an exception
if validation fails. Create an empty configuration complete with a
new populated instance of the data model and a execute the global
scripts. Create the two queues to handle events and set the global
continue variable to true. Call executeTransitionContent on the
initial transition that is a child of scxml. Then call enterState
on the initial transition. Finally, start the interpreter's event
loop.
procedure
interpret(doc): expandScxmlSource(doc)if
(!valid(doc)) {fail with error} configuration =new
Set() previousConfiguration =new
Set() datamodel =new
Datamodel(doc) executeGlobalScriptElements(doc) internalQueue =new
Queue() externalQueue =new
BlockingQueue() continue =true
executeTransitionContent([doc.initial.transition]) enterState([doc.initial.transition]) startEventLoop()
procedure
startEventLoop()The interpreter's event loop has two main
parts. First it selects enabled transitions. Then it executes
Upon entering the selected transitions. It stays in a continuous loop of
selecting state machine, we take all
internally enabled transitions, namely those that don't require an
event and executing transitions
until those that are triggered by
internal events. (Internal events can only be generated by
the interpreter is finished. The details of
how it selects state machine itself.)
When all such transitions are
specified have been taken, we
move to achieve the desired run to completion semantics and final
processing. main event loop, which is
driven by external events.
procedure
procedure startEventLoop():
previousConfiguration = null;
initialStepComplete = false;
until(initialStepComplete):
enabledTransitions = selectTransitions(null)
if (enabledTransitions.isEmpty()):
internalEvent = internalQueue.dequeue()// this call returns immediately if no event is available
if (internalEvent):
datamodel.assignValue("event", internalEvent)
enabledTransitions = selectTransitions(internalEvent)
if (enabledTransitions):
microstep(enabledTransitions.toList()
else:
initialStepComplete = true
mainEventLoop()
procedure
mainEventLoop()The interpreter's event This loop enforces the
run runs until we enter a top-level
final state or an external entity cancels processing. In either
case 'continue' will be set to completion semantics false
(see EnterStates, below, for termination by only breaking at entering a
top-level final state.)
Each iteration through the
end of handling all loop consists of the
microsteps associated with three main
steps: 1) execute any given event. It
accomplishes this by each and every time <invoke> tags for atomic states that we entered on
the last iteration through the loop enforcing 2) Wait for
an ordering on which transitions are
selected. First the interpreter checks to see if there are
external event and then execute any
eventless transitions that need to be taken. If there are it triggers 3) Take any then
they subsequent internally enabled
transitions, namely those that don't require an event or that
are executed triggered by the microstep
being performed and the next iteration of the loop continues. If
there were no eventless transitions to execute then the internal
event queue is checked and if there is an internal
event then transitions are selected based on
this event. If there were transitions
selected based on this
This event then these are executed by the microstep being performed
and the next iteration of the loop continues. If there were no transitions enabled then we
check if we have reached a final state by checking if continue is
true. If continue is false the statemachine is done and we break
out of thus enforces run-to-completion
semantics, in which the startEventLoop.
If continue is true then we grab system
process an external event from
and then takes all the external event queue, blocking if necessary. Once we
have 'follow-up' transitions that
the processing has enabled before looking for
another external event we perform the
appropriate data model manipulation related to finalizing
event. For example, suppose that the
external event queue contains events e1 and e2 and modifying the data model with the event information. Finally we select transitions that
were enabled by this event. machine is
in state s1. If there were transitions
enabled by processing e1 takes
the machine to s2 and generates
internal event we execute them by the microstep function
e3, and start the
next iteration of s2 contains a
transition t triggered by e3, the loop.
If there were system is guaranteed to
take t, no matter what
transitions selected s2 or other states have that would be triggered by
e2. Note that this is true even though e2 was
already in the external event we also
start queue when e3 was generated. In
effect, the next iteration
algorithm treats the processing of
e3 as finishing up the loop. processing of
e1.
procedure startEventLoop(): while (): enabledTransitions = selectTransitions(null) (enabledTransitions.isEmpty() && !internalQueue.isEmpty()): enabledTransitions = selectTransitions(internalQueue.dequeue()) (enabledTransitions.isEmpty()enabledTransitions.isEmpty() && !internalQueue.isEmpty(): (continue): ee = externalQueue.dequeue() datamodel.assignID("event",ee) enabledTransitions = selectTransitions(ee) : (!enabledTransitions.isEmpty()):procedure
procedure mainEventLoop(): while(continue):for
state in configuration.diff(previousConfiguration):if
(isAtomic(state)):if
state.invoke: state.invokeid = executeInvoke(state.invoke) datamodel.assignValue(state.invoke.attribute('idlocation'),state.invokeid) previousConfiguration = configuration externalEvent = externalQueue.dequeue() // this call blocks until an event is available datamodel.assignValue("event",externalEvent) enabledTransitions = selectTransitions(externalEvent) if (enabledTransitions): microstep(enabledTransitions.toList()) // now take any newly enabled null transitions and any transitions triggered by internal events macroStepComplete = false; until(macroStepComplete): enabledTransitions = selectEventlessTransitions() if (enabledTransitions.isEmpty()): internalEvent = internalQueue.dequeue()// this call returns immediately if no event is available if (internalEvent): datamodel.assignValue("event", internalEvent) enabledTransitions = selectTransitions(internalEvent) if (enabledTransitions): microstep(enabledTransitions.toList() else: macroStepComplete = true // if we get here, we have reached a top-level final state or some external entity has set continue to false exitInterpreter()
procedure
exitInterpreter()The purpose of this procedure
is to exit the
current SCXML process by halting
exiting all active states. If the
interpreter's machine is in a top-level final state, a Done
event loop. It does so by setting the global
variable continue to is
generated.
procedure
exitInterpreter(): inFinalState = false statesToExit = new Set(configuration)for
sin
statesToExit.toList().sort(exitOrder) for content in s.onexit: executeContent(content) for inv in s.invoke: cancelInvoke(inv)if
(isFinalState(s) && isScxmlState(s.parent())): inFinalState = true configuration.delete(s) if (inFinalState): sendDoneEvent(???)
false function
This will terminate function selects all transitions that are enabled
in the outer as well as
current configuration that do not require an
event trigger. First test if the inner
loop. Note, however, state has been
preempted by a transition that has already been selected and
that any current microstep will
first cause the
state to be completely
exited when the transition is taken.
If the state has not been preempted, find a
transition with no 'event' attribute whose condition evaluates
to true
.If multiple matching transitions are present, take the
first in document order. If none are present, search in the state's
ancestors in ancestory order until one is found. As soon as such a
transition is found, add it to enabledTransitions
,and proceed to the next atomic state in the
configuration. If no such transition is found in the state or its
ancestors, proceed to the next state in the configuration. When all
atomic states have been visited and transitions selected, return
the set of enabled transitions.
exitInterpreter(): continue =function
selectEventlessTransitions(event): enabledTransitions =new
Set() atomicStates = configuration.toList().filter(isAtomicState)for
statein
atomicStates: if !(isPreempted(s, enabledTransitions)): loop:for
sin
[state].append(getProperAncestors(state,null
)):for
tin
s.transition:if
( t.attribute('event') ==null
&& conditionMatch(t)) enabledTransitions.add(t)break
loopreturn
enabledTransitions
function
selectTransitions(event)The purpose of the selectTransitions()
procedure
is to collect the transitions that are
enabled by this event in a given the current
configuration.
Create an empty set of enabledTransitions
. For
each atomic state in the configuration, first check if the event is the result of an <invoke> in
this state. If so, apply any <finalize> code in the state.
Next test if the state has been preempted by a transition
that has already been selected and that will cause the state to be
exited when the transition is taken. If the state has not been
preempted, find a transition whose 'event' attribute is either empty or matches event
and
whose condition evaluates to true
. (N.B. If event is null only transitions with empty event
attributes match it.) If multiple matching transitions are
present, take the first in document order. If none are present,
search in the state's ancestors in ancestory order until one is
found. As soon as such a transition is found, add it to
enabledTransitions
, and proceed to the next atomic
state in the configuration. If no such transition is found in the
state or its ancestors, proceed to the next state in the
configuration. When all atomic states have been visited and
transitions selected, return the set of enabled transitions.
function
selectTransitions(event): enabledTransitions =new
Set() atomicStates = configuration.toList().filter(isAtomicState)for
statein
atomicStates: if (event.attribute('invokeid') != null && state.invokeid = event.invokeid): //event is the result of an <invoke> in this state applyFinalize(state, event) if !(isPreempted(s, enabledTransitions)): loop:for
sin
[state].append(getProperAncestors(state,null
)):for
tin
s.transition:&& conditionMatch(t)) || (event != && nameMatch(event,t) && conditionMatch(t))):if
(t.attribute('event')!= null && isPrefix(t.attribute('event'), event.name) && conditionMatch(t)): enabledTransitions.add(t)break
loopreturn
enabledTransitions
procedure function
Return true if a transition T in transitionList exits an ancestor of state s. In this case, taking T will pull the state machine out of s and we say that it preempts the selection of a transition from s. Such preemption will occur only if s is a descendant of a parallel region and T exits that region. If we did not do this preemption check, we could end up in an illegal configuration, namely one in which there were multiple active states that were not all descendants of a common parallel ancestor.
isPreempted?(s transitionList): boolean preempted = falsefunction
isPreempted(s transitionList): preempted = false for t in transitionList: if (t.attribute('target') != null): LCA = findLCA([t.parent()].append(getTargetStates(t)))if (isDescendant(s,LCA)): preempted = true break;if (isDescendant(s,LCA)): preempted = true break return preempted
procedure
microstep(enabledTransitions)The purpose of the microstep procedure
is to
process the set of transitions enabled by an external event, an
internal event, or by the presence or absence of certain values in
the datamodel at the current point in time. The processing of the
enabled transitions must be done in parallel ('lock step') in the
sense that their source states must first be exited, then their
actions must be executed, and finally their target states
entered.
procedure
microstep(enabledTransitions):
exitStates(enabledTransitions)
executeTransitionContent(enabledTransitions)
enterStates(enabledTransitions)
procedure
exitStates(enabledTransitions)Create an empty statesToExit
set. For each
transition t
in enabledTransitions
, if
t
is targetless then do nothing, else let
LCA
be the least common ancestor state of the source
state and target states of t
. Add to the
statesToExit
set all states in the configuration that
are descendants of LCA
. Convert the
statesToExit
set to a list and sort it in
exitOrder
.
For each state s
in the list, if s
has
a deep history state h
, set the history value of
h
to be the list of all atomic descendants of
s
that are members in the current configuration, else
set its value to be the list of all immediate children of
s
that are members of the current configuration. Again
for each state s
in the list, first execute any onexit
handlers, then cancel any ongoing invocations, and finally remove
s
from the current configuration.
procedure
exitStates(enabledTransitions): statesToExit =new
Set()for
tin
enabledTransitions:if
(t.attribute('target') !=null
): LCA = findLCA([t.parent()].append(getTargetStates(t)))for
sin
configuration.toList():if
(isDescendant(s,LCA)): statesToExit.add(s) statesToExit = statesToExit.toList().sort(exitOrder)for
sin
statesToExit:for
hin
s.history: f = (h.attribute('type') == "deep") ? lambda(s0): isAtomicState(s0) && isDescendant(s0,s) : lambda(s0): s0.parent() == s historyValue[h.attribute('id')] = configuration.toList().filter(f)for
sin
statesToExit:for
contentin
s.onexit: executeContent(content)for
invin
s.invoke: cancelInvoke(inv) configuration.delete(s)
procedure
executeTransitionContent(enabledTransitions)For each transition in the list of
enabledTransitions
, execute its executable
content.
procedure
executeTransitions(enabledTransitions):for
tin
enabledTransitions: executeContent(t)
procedure
enterStates(enabledTransitions)Create an empty statesToEnter
set, and an empty
statesForDefaultEntry
set. For each transition
t
in enabledTransitions
, if
t
is targetless then do nothing, else let
LCA
be the least common ancestor state of the source
state and target states of t
. For each target state
s
, if s
is a history state then add
either the history values associated with s
or
s
's default target to statesToEnter
.
Else (if s
is not a history state), add s
to statesToEnter
. Convert statesToEnter
to a list and sort it in
.enterOrder enterorder
For each state s
in the list, first add
s
to the current configuration, then invoke any
external processes specified in <invoke> elements and assign
their
s to the datamodel, keyed on the
<invoke> element's sessionID sessionidID,
id, then execute any onentry handlers,
and finally, if s
is a final state, generate relevant
Done
events. If we have reached a top-level final
state, exit the interpreter.
procedure
enterStates(enabledTransitions): statesToEnter =new
Set() statesForDefaultEntry =new
Set()for
tin
enabledTransitions:if
(t.attribute('target') !=null
): LCA = findLCA([t.parent()].append(getTargetStates(t)))for
sin
getTargetStates(t):if
(isHistoryState(s)):if
(historyValue[s.attribute('id')] !=null
):for
s0in
historyValue[s.attribute('id')]: addStatesToEnter(s0,LCA,statesToEnter,statesForDefaultEntry)else
:for
s0in
getTargetStates(s.transition): addStatesToEnter(s0,LCA,statesToEnter,statesForDefaultEntry)else
: addStatesToEnter(s,LCA,statesToEnter,statesForDefaultEntry)statesToEnte ): r = statesToEnter.toList().sort(enterOrder)statesToEnter = statesToEnter.toList().sort(enterOrder)for
sin
statesToEnter: configuration.add(s)s.invoke: sessionID = executeInvoke(inv) datamodel.assignValue(inv.attribute('ID'),sessionID)for
contentin
s.onentry: executeContent(content)if
(statesForDefaultEntry.member(s)): executeContent(s.initial.transition.children())if
(isFinalState(s)): parent = s.parent() grandparent = parent.parent() internalQueue.enqueue(parent.attribute('id') + ".Done")if
(isParallelState(grandparent)):if
(getChildStates(grandparent).every(isInFinalState)): internalQueue.enqueue(grandparent.attribute('id') + ".Done")for
sin
configuration.toList():if
(isFinalState(s) && isScxmlState(s.parent())):exitInterpreter()continue = false;
procedure
addStatesToEnter(s,root,statesToEnter,statesForDefaultEntry)The purpose of this procedure
is to add to
statesToEnter
all states that must be entered as a
result of entering state s
. These include ancestors
of s
, parallel siblings of s
or its
ancestors, and s
's default children, if
s
is a parallel or compound state. Note that this
procedure
permanently modifies both
statesToEnter
and statesForDefaultEntry
.
First, add s
to statesToEnter
. Then,
if s
is a parallel state, add each of s
's children to statesToEnter
. Else, if s
is a compound state, add s
to
statesForDefaultEntry
and add its default initial
state to statesToEnter
. Finally, for each ancestor
anc
of s
, add anc
to
statesToEnter
and if anc
is a parallel
state, add the children of anc
that does not have a
descendant on statesToEnter
to
statesToEnter
.
procedure
addStatesToEnter(s,root,statesToEnter,statesForDefaultEntry): statesToEnter.add(s)if
(isParallelState(s)):for
childin
getChildStates(s): addStatesToEnter(child,s,statesToEnter,statesForDefaultEntry)elif
(isCompoundState(s)): statesForDefaultEntry.add(s) addStatesToEnter(getDefaultInitialState(s),s,statesToEnter,statesForDefaultEntry)for
ancin
getProperAncestors(s,root): statesToEnter.add(anc)if
(isParallelState(anc)):for
pChildin
getChildStates(anc):if
(!statesToEnter.toList().some(lambda(s): isDescendant(s,anc))): addStatesToEnter(pChild,anc,statesToEnter,statesForDefaultEntry)
procedure
isInFinalState(s)Return true
if state s
is a compound
<state> and one of its children is a <final> state and
is a member of the configuration, or if s
is a
<parallel> state and isInFinalState
is
true
of all its children.
function
isInFinalState(s):if
(isCompoundState(s)):return
getChildStates(s).some(lambda(s): isFinalState(s) && configuration.member(s))elif
(isParallelState(s)):return
getChildStates(s).every(isInFinalState)else
:return
false
function
findLCA(stateList)Return the state s
such that s
is a
proper ancestor of all states on stateList
and no
descendant of s
has this property. Note that there is
guaranteed to be such a state since the <scxml> element
(which we treat as a state here) is a common ancestor of all
states. Note also that since we are speaking of proper ancestor
(parent or parent of a parent, etc.) the LCA is never a member of
stateList
.
function
findLCA
(stateList):for
anc in getProperAncestors(stateList.head(),null):if
(stateList.tail().every(lambda(s): isDescendant(s,anc))):return
anc
There are a number of ways of defining the semantics of <anchor>. We choose the following because it shows that, except for the rollback of the data model, <anchor> can be viewed as a syntactic shortcut that does not extend the basic Harel semantics. We emphasize that implementations are required only to behave as if they assigned the following interpretation to <anchor> and that simpler and more efficient implementations are possible.
First, we add a special branch 'anchors' to the data model, with
a child for each anchor type defined in the document. Thus if the
document defines anchor types "foo" and "bar", the data model will
have paths 'anchors.foo' and 'anchors.bar'. Whenever the state
machine enters a state with an <anchor> element, it sets the
value of the corresponding anchor entry in the datamodel to the
ID id of
that state. Thus if a <state> with ID id 'state27'
defines an <anchor> with 'type' "foo", whenever the state
machine visits this state, it sets 'anchors.foo; to 'state27'.
Furthermore, the state machine automatically adds the 'anchors'
branch to the snapshot specified in the <anchor> element.
Now any <transition> which specifies an 'anchor' is
replaced with a set of <transition>s, one for each
<state> that defines that <anchor>. Each of the
<transition>s takes as its 'target' one of the <state>s
that defines the <anchor>. Furthermore, an extra clause is
added to the 'cond' of the original <transition>, specifying
that the corresponding location in the data model match the target
<state>'s ID. id. Finally, a default transition is added
reentering the current <state>. For example, if the anchor
type "foo" is defined in <state>s 'state27' and 'state33',
then in <state> 'thisState', a transition with "event"
"someEvent", "cond" "someCond" and "anchor" 'foo' will be replaced
by three transitions, as shown below:
<transition event="someEvent" cond="someCond" anchor="foo"/>
is equivalent to
<transition event="someEvent" cond="datamodel.anchors.foo==state27 && someCond" target="state27"/> <transition event="someEvent" cond="datamodel.anchors.foo==state33 && someCond" target="state33"/> <transition event="someEvent" cond="someCond" target="state33"/> target="thisState"/>
At runtime when "someEvent" is raised and "someCond" is true, if
either state27 or state33 has been visited, 'datamodel.anchors.foo'
will have the corresponding stateID
stateid as its value and the
corresponding transition will be selected. The only complication is
that the transitions must retain the original 'anchor' attribute,
so that the datamodel must be rolled back to the snapshot specified
in the corresponding <anchor> element. Note that the
'anchors' branch must be automatically added to this snapshot, so
that it will be automatically rolled back as well. (This has the
effect of erasing any intermediate anchors that have been visited
since the target state was exited.) If neither state27 nor state33
has been visited, the third transition will be taken, causing the
state machine to exit and reenter 'thisState' without any rollback
of the datamodel.
In some applications, it is useful for a state machine to behave non-deterministically according to a probability distribution. For example, we may want to have a state S1 which transitions to S2 30% of the time and to S3 70% of the time. Such behavior can be modeled in SCXML as long as the executable content includes a random number generator. In the example below, we use ECMAScript to generate a random number between 0.0 and 1.0 in the <onentry> handler of state S1. S1 has two transitions, both triggered by E1, going to states S2 and S3. S1 takes the first transition if the variable <rand> is ≤ 0.3 but the second transition if <rand> is > 0.3. Since <rand> is evenly distributed between 0.0 and 1.0, S1 will transition to S2 30% of the time and S3 70% of the time on event E1. Note that it is important that the random number generation take place outside the <cond> clause of the transition since there are no guarantees of when or how often that will be evaluated.
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initialstate="S1"><scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initialstate="S1"> <state id="S1"> <datamodel> <data name="rand"> </datamodel> <onentry> <assign name="rand" expr="Math.random()"/> </onentry><transition event="E1" cond="rand ‹= 0.3" target="S2"/><transition event="E1" cond="rand <= 0.3" target="S2"/> <transition event="E1" cond="rand > 0.3" target="S3"> </state> <state id="S2"/> <state id="S3"/> </scxml>
The following schemas contain common definitions that are used by the schemas for specific modules and profiles.
scxml-datatypes.xsd
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"><!-- edited with XMLSpy v2008 sp1 (http://www.altova.com) by Alicia Fraumeni (Genesys Telecommunications Laboratories) --> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:annotation> <xsd:documentation> XML Schema datatypes for SCXML Defines containers for the SCXML datatypes, many of these imported from other specifications and standards. </xsd:documentation><xsd:documentation source="scxml-copyright.xsd" /><xsd:documentation source="scxml-copyright.xsd"/> </xsd:annotation> <xsd:simpleType name="Exmode.datatype"> <xsd:annotation> <xsd:documentation>execution mode </xsd:documentation> </xsd:annotation> <xsd:restriction base="xsd:NMTOKEN"> <xsd:enumeration value="lax" /> <xsd:enumeration value="strict" /> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="ExprLang.datatype"> <xsd:annotation> <xsd:documentation> expression languageexecution mode </xsd:documentation> </xsd:annotation> <xsd:restriction base="xsd:NMTOKEN"><xsd:enumeration value="XPath20"/><xsd:enumeration value="lax"/> <xsd:enumeration value="strict"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="Profile.datatype"> <xsd:annotation> <xsd:documentation>profileprofile </xsd:documentation> </xsd:annotation> <xsd:restriction base="xsd:NMTOKEN"> <xsd:enumeration value="minimum"/> <xsd:enumeration value="xpath"/> <xsd:enumeration value="ecmascript"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="HistoryType.datatype"> <xsd:restriction base="xsd:string"><xsd:enumeration value="shallow" /> <xsd:enumeration value="deep" /><xsd:enumeration value="shallow"/> <xsd:enumeration value="deep"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="Boolean.datatype"> <xsd:annotation> <xsd:documentation> Boolean: true or false only </xsd:documentation> </xsd:annotation> <xsd:restriction base="xsd:NMTOKENS"><xsd:enumeration value="true" /> <xsd:enumeration value="false" /><xsd:enumeration value="true"/> <xsd:enumeration value="false"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="URI.datatype"> <xsd:annotation> <xsd:documentation> The xsd:anyURI type and thus URI references in SCXML documents may contain a wide array of international characters. Implementers should reference RFC 3987 and the "Character Model for the World Wide Web 1.0: Resource Identifiers" in order to provide appropriate support for these characters in VoiceXML documents and when processing values of this type or mapping them to URIs. </xsd:documentation> </xsd:annotation><xsd:restriction base="xsd:anyURI" /><xsd:restriction base="xsd:anyURI"/> </xsd:simpleType> <xsd:simpleType name="Integer.datatype"> <xsd:annotation> <xsd:documentation>Non-negative integer</xsd:documentation> </xsd:annotation><xsd:restriction base="xsd:nonNegativeInteger" /><xsd:restriction base="xsd:nonNegativeInteger"/> </xsd:simpleType> <xsd:simpleType name="Duration.datatype"> <xsd:annotation> <xsd:documentation> Time designation following Time [CSS2]; negative numbers not allowed </xsd:documentation> </xsd:annotation> <xsd:restriction base="xsd:string"><xsd:pattern value="(\+)?([0-9]*\.)?[0-9]+(ms|s)" /><xsd:pattern value="(\+)?([0-9]*\.)?[0-9]+(ms|s)"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="ContentType.datatype"> <xsd:annotation> <xsd:documentation>Content type [RFC2045]</xsd:documentation> </xsd:annotation><xsd:list itemType="xsd:token" /><xsd:list itemType="xsd:token"/> </xsd:simpleType> <xsd:simpleType name="EventType.datatype"> <xsd:annotation> <xsd:documentation> EventType </xsd:documentation> </xsd:annotation> <xsd:restriction base="xsd:token"> <xsd:pattern value="[\c\*]+"/> </xsd:restriction> </xsd:simpleType> <!-- Defines the default CondLang datatype. --> <xsd:simpleType name="CondLang.datatype"> <xsd:annotation> <xsd:documentation> Conditional language is expression which must evaluate to Boolean True or False. The expression language must define In(stateID) as a valid expression. </xsd:documentation> </xsd:annotation> <xsd:restriction base="xsd:string"/> </xsd:simpleType> <!-- Defines the default LocLang datatype. --> <xsd:simpleType name="LocLang.datatype"> <xsd:annotation> <xsd:documentation> Location language is expression identifying a location in the datamodel. </xsd:documentation> </xsd:annotation> <xsd:restriction base="xsd:string"/> </xsd:simpleType> <!-- Defines the default ValueLang datatype. --> <xsd:simpleType name="ValueLang.datatype"> <xsd:annotation> <xsd:documentation> Value language is expression return a value. </xsd:documentation> </xsd:annotation> <xsd:restriction base="xsd:string"/> </xsd:simpleType> </xsd:schema>
scxml-attribs.xsd
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xsd:annotation> <xsd:documentation><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:annotation> <xsd:documentation> This is the XML Schema common attributes for SCXML </xsd:documentation><xsd:documentation source="scxml-copyright.xsd"/> </xsd:annotation> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"> <xsd:annotation> <xsd:documentation> This import brings in the XML namespace attributes The module itself does not provide the schemaLocation and expects the driver schema to provide the actual SchemaLocation. </xsd:documentation> </xsd:annotation> </xsd:import> <xsd:include schemaLocation="scxml-datatypes.xsd"> <xsd:annotation> <xsd:documentation> This include brings in the SCXML datatypes. </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:attributeGroup name="scxml.extra.attribs"> <xsd:annotation> <xsd:documentation>group allowing attributes from other namespaces</xsd:documentation> </xsd:annotation> <xsd:anyAttribute namespace="##other" processContents="lax" /> </xsd:attributeGroup> <xsd:attributeGroup name="Fetchtimeout.attrib"> <xsd:annotation> <xsd:documentation>Used in Cache.attribs</xsd:documentation> </xsd:annotation> <xsd:attribute name="Fetchtimeout" type="Duration.datatype"/> </xsd:attributeGroup> <xsd:attributeGroup name="Maxage.attrib"> <xsd:annotation> <xsd:documentation>Used in Cache.attribs</xsd:documentation> </xsd:annotation> <xsd:attribute name="maxage" type="Integer.datatype"/> </xsd:attributeGroup> <xsd:attributeGroup name="Maxstale.attrib"> <xsd:annotation> <xsd:documentation>Used in Cache attribs</xsd:documentation> </xsd:annotation> <xsd:attribute name="maxstale" type="Integer.datatype"/> </xsd:attributeGroup> <xsd:attributeGroup name="Cache.attribs"> <xsd:annotation> <xsd:documentation>Cache attributes to control caching behavior</xsd:documentation><xsd:documentation source="scxml-copyright.xsd"/> </xsd:annotation><xsd:attributeGroup ref="Fetchtimeout.attrib"/> <xsd:attributeGroup ref="Maxage.attrib"/> <xsd:attributeGroup ref="Maxstale.attrib"/> </xsd:attributeGroup><xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"> <xsd:annotation> <xsd:documentation> This import brings in the XML namespace attributes The module itself does not provide the schemaLocation and expects the driver schema to provide the actual SchemaLocation. </xsd:documentation> </xsd:annotation> </xsd:import> <xsd:include schemaLocation="scxml-datatypes.xsd"> <xsd:annotation> <xsd:documentation> This include brings in the SCXML datatypes. </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:attributeGroup name="Fetchtimeout.attrib"> <xsd:annotation> <xsd:documentation>Used in Cache.attribs</xsd:documentation> </xsd:annotation> <xsd:attribute name="fetchtimeout" type="Duration.datatype"/> </xsd:attributeGroup> <xsd:attributeGroup name="Maxage.attrib"> <xsd:annotation> <xsd:documentation>Used in Cache.attribs</xsd:documentation> </xsd:annotation> <xsd:attribute name="maxage" type="Integer.datatype"/> </xsd:attributeGroup> <xsd:attributeGroup name="Maxstale.attrib"> <xsd:annotation> <xsd:documentation>Used in Cache attribs</xsd:documentation> </xsd:annotation> <xsd:attribute name="maxstale" type="Integer.datatype"/> </xsd:attributeGroup> <xsd:attributeGroup name="Cache.attribs"> <xsd:annotation> <xsd:documentation>Cache attributes to control caching behavior</xsd:documentation> </xsd:annotation> <xsd:attributeGroup ref="Fetchtimeout.attrib"/> <xsd:attributeGroup ref="Maxage.attrib"/> <xsd:attributeGroup ref="Maxstale.attrib"/> </xsd:attributeGroup> </xsd:schema>
scxml-contentmodels.xsd
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:annotation> <xsd:documentation>XML Schema content models for SCXML * scxml.extra.content Defines SCXML shared content models. </xsd:documentation> <xsd:documentation source="scxml-copyright.xsd" />XML Schema content models for SCXML * scxml.extra.content * content * scxml.extra.attribs Defines SCXML shared content models. </xsd:documentation> <xsd:documentation source="scxml-copyright.xsd"/> </xsd:annotation> <xsd:attributeGroup name="scxml.extra.attribs"> <xsd:annotation> <xsd:documentation>group allowing attributes from other namespaces</xsd:documentation> </xsd:annotation> <xsd:anyAttribute namespace="##other" processContents="lax"/> </xsd:attributeGroup> <xsd:group name="scxml.extra.content"><xsd:annotation> <xsd:documentation> group allowing elements from other namespaces </xsd:documentation> </xsd:annotation><xsd:annotation> <xsd:documentation> group allowing elements from other namespaces </xsd:documentation> </xsd:annotation> <xsd:sequence><xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/> </xsd:sequence><xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <!-- content --> <xsd:attributeGroup name="scxml.content.attlist"> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.content.content"> <xsd:sequence> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <xsd:complexType name="scxml.content.type" mixed="true"> <xsd:group ref="scxml.content.content"/> <xsd:attributeGroup ref="scxml.content.attlist"/> </xsd:complexType> <xsd:element name="content" type="scxml.content.type"/> </xsd:schema>
scxml-module-core.xsd
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"><!-- edited with XMLSpy v2008 sp1 (http://www.altova.com) by Alicia Fraumeni (Genesys Telecommunications Laboratories) --> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:annotation> <xsd:documentation>This is the XML Schema core module for SCXML * scxmlThis is the XML Schema core module for SCXML * scxml * state * initial * onexit * onentry * transition * parallel * final * history * if * elseif * else* event* raise * logThe core module defines these elements and their attributes. </xsd:documentation> <xsd:documentation source="scxml-copyright.xsd" />* donedata The core module defines these elements and the attributes. </xsd:documentation> <xsd:documentation source="scxml-copyright.xsd"/> </xsd:annotation> <xsd:include schemaLocation="scxml-datatypes.xsd"> <xsd:annotation> <xsd:documentation> Includes common SCXML datatypes </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:include schemaLocation="scxml-attribs.xsd"> <xsd:annotation> <xsd:documentation> Includes common SCXML attributes </xsd:documentation> </xsd:annotation> </xsd:include><!-- core executable content model --><xsd:include schemaLocation="scxml-contentmodels.xsd"> <xsd:annotation> <xsd:documentation> This module defines Common content model extensions for SCXML </xsd:documentation> </xsd:annotation> </xsd:include> <!-- core executable content model --> <xsd:group name="scxml.core.executablecontent"><xsd:choice> <xsd:group ref="scxml.extra.content"/> <xsd:element ref="event"/> <xsd:element ref="if"/> <xsd:element ref="log"/> </xsd:choice><xsd:choice> <xsd:group ref="scxml.extra.content"/> <xsd:element ref="raise"/> <xsd:element ref="if"/> <xsd:element ref="log"/> </xsd:choice> </xsd:group><!-- scxml --><!-- scxml --> <xsd:attributeGroup name="scxml.scxml.attlist"> <xsd:attribute name="initial" type="xsd:IDREFS"/> <xsd:attribute name="name" type="xsd:NMTOKEN"/><xsd:attribute name="version" type="xsd:string" fixed="1.0" use="required"/><xsd:attribute name="version" type="xsd:decimal" use="required" fixed="1.0"/> <xsd:attribute name="profile" type="Profile.datatype"/><xsd:attribute name="exmode" type="Exmode.datatype" default="lax"/><xsd:attribute name="exmode" type="Exmode.datatype" default="lax"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.scxml.mix"> <xsd:choice> <xsd:element ref="initial"/> <xsd:element ref="state" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="parallel" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="final" minOccurs="0" maxOccurs="unbounded"/> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.scxml.content"> <xsd:sequence><xsd:choice minOccurs="1" maxOccurs="unbounded"> <xsd:element ref="initial" minOccurs="0" maxOccurs="1" /> <xsd:element ref="state" minOccurs="0" maxOccurs="unbounded" /> <xsd:element ref="parallel" minOccurs="0" maxOccurs="unbounded" /> <xsd:element ref="final" minOccurs="0" maxOccurs="unbounded" /> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded" /> </xsd:choice><xsd:group ref="scxml.scxml.mix" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <xsd:complexType name="scxml.scxml.type"><xsd:group ref="scxml.scxml.content" /> <xsd:attributeGroup ref="scxml.scxml.attlist" /><xsd:group ref="scxml.scxml.content"/> <xsd:attributeGroup ref="scxml.scxml.attlist"/> </xsd:complexType> <xsd:element name="scxml" type="scxml.scxml.type"/><xsd:element name="scxml" type="scxml.scxml.type" /> <!-- state --><!-- state --> <xsd:attributeGroup name="scxml.state.attlist"><xsd:attribute name="id" type="xsd:ID" use="required" /> <xsd:attribute name="src" type="URI.datatype" /><xsd:attribute name="id" type="xsd:ID" use="required"/> <xsd:attribute name="src" type="URI.datatype"/> <xsd:attribute name="initial" type="xsd:IDREFS"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup><xsd:group name="scxml.state.mix"> <xsd:choice> <xsd:element ref="onentry" minOccurs="0" maxOccurs="1" /> <xsd:element ref="onexit" minOccurs="0" maxOccurs="1" /> <xsd:element ref="transition" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="initial" minOccurs="0" maxOccurs="1"/> <xsd:element ref="state" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="parallel" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="final" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="history" minOccurs="0" maxOccurs="unbounded"/> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded" /> </xsd:choice><xsd:group name="scxml.state.mix"> <xsd:choice> <xsd:element ref="onentry" minOccurs="0" maxOccurs="1"/> <xsd:element ref="onexit" minOccurs="0" maxOccurs="1"/> <xsd:element ref="transition" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="initial" minOccurs="0" maxOccurs="1"/> <xsd:element ref="state" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="parallel" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="final" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="history" minOccurs="0" maxOccurs="unbounded"/> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.state.content"><xsd:sequence> <xsd:group ref="scxml.state.mix" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence><xsd:sequence> <xsd:group ref="scxml.state.mix" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <xsd:complexType name="scxml.state.type"><xsd:sequence> <xsd:group ref="scxml.state.content"/> </xsd:sequence> <xsd:attributeGroup ref="scxml.state.attlist" /><xsd:sequence> <xsd:group ref="scxml.state.content"/> </xsd:sequence> <xsd:attributeGroup ref="scxml.state.attlist"/> </xsd:complexType> <xsd:element name="state" type="scxml.state.type"/><xsd:element name="state" type="scxml.state.type" /> <!-- initial --><!-- initial --> <xsd:attributeGroup name="scxml.initial.attlist"> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.initial.mix"><xsd:choice> <xsd:element ref="transition" minOccurs="1" maxOccurs="1" /> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice><xsd:choice> <xsd:element ref="transition" minOccurs="0" maxOccurs="unbounded"/> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.initial.content"><xsd:sequence> <xsd:group ref="scxml.initial.mix" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <xsd:complexType name="scxml.initial.type" > <xsd:group ref="scxml.initial.content" /> <xsd:attributeGroup ref="scxml.initial.attlist" /><xsd:sequence> <xsd:group ref="scxml.initial.mix" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <xsd:complexType name="scxml.initial.type"> <xsd:group ref="scxml.initial.content"/> <xsd:attributeGroup ref="scxml.initial.attlist"/> </xsd:complexType> <xsd:element name="initial" type="scxml.initial.type"/><xsd:element name="initial" type="scxml.initial.type" /> <!-- onentry --><!-- onentry --> <xsd:attributeGroup name="scxml.onentry.attlist"> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.onentry.content"> <xsd:sequence><xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded" /><xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group><xsd:complexType name="scxml.onentry.type" > <xsd:group ref="scxml.onentry.content" /> <xsd:attributeGroup ref="scxml.onentry.attlist" /><xsd:complexType name="scxml.onentry.type"> <xsd:group ref="scxml.onentry.content"/> <xsd:attributeGroup ref="scxml.onentry.attlist"/> </xsd:complexType> <xsd:element name="onentry" type="scxml.onentry.type"/><xsd:element name="onentry" type="scxml.onentry.type" /> <!-- onexit --><!-- onexit --> <xsd:attributeGroup name="scxml.onexit.attlist"> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.onexit.content"> <xsd:sequence><xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded" /><xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group><xsd:complexType name="scxml.onexit.type" > <xsd:group ref="scxml.onexit.content" /> <xsd:attributeGroup ref="scxml.onexit.attlist" /><xsd:complexType name="scxml.onexit.type"> <xsd:group ref="scxml.onexit.content"/> <xsd:attributeGroup ref="scxml.onexit.attlist"/> </xsd:complexType> <xsd:element name="onexit" type="scxml.onexit.type"/><xsd:element name="onexit" type="scxml.onexit.type" /> <!-- transition --><!-- transition --> <xsd:attributeGroup name="scxml.transition.attlist"><xsd:attribute name="event" type="xsd:NMTOKEN" /> <xsd:attribute name="cond" type="CondLang.datatype" /> <xsd:attribute name="target" type="xsd:IDREFS" /> <xsd:attribute name="anchor" type="xsd:NMTOKEN" /><xsd:attribute name="event" type="EventType.datatype"/> <xsd:attribute name="cond" type="CondLang.datatype"/> <xsd:attribute name="target" type="xsd:IDREFS"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.transition.content"> <xsd:sequence><xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded" /><xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group><xsd:complexType name="scxml.transition.type" > <xsd:group ref="scxml.transition.content" /> <xsd:attributeGroup ref="scxml.transition.attlist" /><xsd:complexType name="scxml.transition.type"> <xsd:group ref="scxml.transition.content"/> <xsd:attributeGroup ref="scxml.transition.attlist"/> </xsd:complexType> <xsd:element name="transition" type="scxml.transition.type"/><xsd:element name="transition" type="scxml.transition.type" /> <!-- parallel --><!-- parallel --> <xsd:attributeGroup name="scxml.parallel.attlist"><xsd:attribute name="id" type="xsd:ID" use="required" /> <xsd:attribute name="src" type="URI.datatype" /><xsd:attribute name="id" type="xsd:ID" use="required"/> <xsd:attribute name="src" type="URI.datatype"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.parallel.mix"> <xsd:choice> <xsd:element ref="onentry" minOccurs="0" maxOccurs="1"/> <xsd:element ref="onexit" minOccurs="0" maxOccurs="1"/> <xsd:element ref="transition" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="state" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="parallel" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="history" minOccurs="0" maxOccurs="unbounded"/> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.parallel.content"> <xsd:sequence><xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element ref="onentry" minOccurs="0" maxOccurs="1" /> <xsd:element ref="onexit" minOccurs="0" maxOccurs="1" /> <xsd:element ref="transition" minOccurs="0" maxOccurs="unbounded" /> <xsd:element ref="state" minOccurs="0" maxOccurs="unbounded" /> <xsd:element ref="parallel" minOccurs="0" maxOccurs="unbounded" /> <xsd:element ref="history" minOccurs="0" maxOccurs="1" /> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice><xsd:group ref="scxml.parallel.mix" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group><xsd:complexType name="scxml.parallel.type" > <xsd:group ref="scxml.parallel.content" /> <xsd:attributeGroup ref="scxml.parallel.attlist" /><xsd:complexType name="scxml.parallel.type"> <xsd:group ref="scxml.parallel.content"/> <xsd:attributeGroup ref="scxml.parallel.attlist"/> </xsd:complexType> <xsd:element name="parallel" type="scxml.parallel.type"/><xsd:element name="parallel" type="scxml.parallel.type" /> <!-- final --><!-- final --> <xsd:attributeGroup name="scxml.final.attlist"><xsd:attribute name="id" type="xsd:ID" use="required" /><xsd:attribute name="id" type="xsd:ID" use="required"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.final.mix"> <xsd:choice> <xsd:element ref="onentry" minOccurs="0" maxOccurs="1"/> <xsd:element ref="onexit" minOccurs="0" maxOccurs="1"/> <xsd:element ref="donedata" minOccurs="0" maxOccurs="1"/> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.final.content"> <xsd:sequence><xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element ref="onentry" minOccurs="0" maxOccurs="1" /> <xsd:element ref="onexit" minOccurs="0" maxOccurs="1" /> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice><xsd:group ref="scxml.final.mix" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group><xsd:complexType name="scxml.final.type" > <xsd:group ref="scxml.final.content" /> <xsd:attributeGroup ref="scxml.final.attlist" /><xsd:complexType name="scxml.final.type"> <xsd:group ref="scxml.final.content"/> <xsd:attributeGroup ref="scxml.final.attlist"/> </xsd:complexType> <xsd:element name="final" type="scxml.final.type"/><xsd:element name="final" type="scxml.final.type" /> <!-- history --><!-- history --> <xsd:attributeGroup name="scxml.history.attlist"><xsd:attribute name="id" type="xsd:ID" use="required" /> <xsd:attribute name="type" type="HistoryType.datatype" /><xsd:attribute name="id" type="xsd:ID" use="required"/> <xsd:attribute name="type" type="HistoryType.datatype"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.history.mix"> <xsd:choice> <xsd:element ref="transition" minOccurs="0" maxOccurs="1"/> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.history.content"><xsd:sequence> <xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element ref="transition" minOccurs="1" maxOccurs="1" /> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:sequence><xsd:sequence> <xsd:group ref="scxml.history.mix" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group><xsd:complexType name="scxml.history.type" > <xsd:group ref="scxml.history.content" /> <xsd:attributeGroup ref="scxml.history.attlist" /><xsd:complexType name="scxml.history.type"> <xsd:group ref="scxml.history.content"/> <xsd:attributeGroup ref="scxml.history.attlist"/> </xsd:complexType> <xsd:element name="history" type="scxml.history.type"/><xsd:element name="history" type="scxml.history.type" /> <!-- if --><!-- if --> <xsd:attributeGroup name="scxml.if.attlist"><xsd:attribute name="cond" type="CondLang.datatype" use="required"/><xsd:attribute name="cond" type="CondLang.datatype" use="required"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.if.mix"> <xsd:choice> <xsd:element ref="elseif" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="else" minOccurs="0" maxOccurs="1"/> <xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.if.content"> <xsd:sequence><xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element ref="elseif" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="else" minOccurs="0" maxOccurs="1"/> <xsd:group ref="scxml.core.executablecontent"/> </xsd:choice><xsd:group ref="scxml.if.mix" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group><xsd:complexType name="scxml.if.type" > <xsd:group ref="scxml.if.content" /> <xsd:attributeGroup ref="scxml.if.attlist" /><xsd:complexType name="scxml.if.type"> <xsd:group ref="scxml.if.content"/> <xsd:attributeGroup ref="scxml.if.attlist"/> </xsd:complexType> <xsd:element name="if" type="scxml.if.type"/><xsd:element name="if" type="scxml.if.type" /> <!-- elseif --><!-- elseif --> <xsd:attributeGroup name="scxml.elseif.attlist"> <xsd:attribute name="cond" type="CondLang.datatype" use="required"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.elseif.mix"> <xsd:choice> <!-- No content for this element --> </xsd:choice> </xsd:group> <xsd:group name="scxml.elseif.content"> <xsd:sequence><xsd:choice> <xsd:group ref="scxml.core.executablecontent" /> </xsd:choice><xsd:group ref="scxml.elseif.mix" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group><xsd:complexType name="scxml.elseif.type" > <xsd:group ref="scxml.elseif.content" /> <xsd:attributeGroup ref="scxml.elseif.attlist" /><xsd:complexType name="scxml.elseif.type"> <xsd:group ref="scxml.elseif.content"/> <xsd:attributeGroup ref="scxml.elseif.attlist"/> </xsd:complexType> <xsd:element name="elseif" type="scxml.elseif.type"/><xsd:element name="elseif" type="scxml.elseif.type" /> <!-- else --><!-- else --> <xsd:attributeGroup name="scxml.else.attlist"> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.else.mix"> <xsd:choice> <!-- No content for this element --> </xsd:choice> </xsd:group> <xsd:group name="scxml.else.content"> <xsd:sequence><xsd:choice> <xsd:group ref="scxml.core.executablecontent" /> </xsd:choice><xsd:group ref="scxml.else.mix" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group><xsd:complexType name="scxml.else.type" > <xsd:group ref="scxml.else.content" /> <xsd:attributeGroup ref="scxml.else.attlist" /><xsd:complexType name="scxml.else.type"> <xsd:group ref="scxml.else.content"/> <xsd:attributeGroup ref="scxml.else.attlist"/> </xsd:complexType> <xsd:element name="else" type="scxml.else.type"/><xsd:element name="else" type="scxml.else.type" /> <!-- event --> <xsd:attributeGroup name="scxml.event.attlist"> <xsd:attribute name="name" type="xsd:NMTOKEN" use="required"/><!-- raise --> <xsd:attributeGroup name="scxml.raise.attlist"> <xsd:attribute name="event" type="xsd:NMTOKEN" use="required"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup><xsd:group name="scxml.event.content"><xsd:group name="scxml.raise.mix"> <xsd:choice> <xsd:element ref="content" minOccurs="0" maxOccurs="1"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.raise.content"> <xsd:sequence><xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/><xsd:group ref="scxml.raise.mix" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group><xsd:complexType name="scxml.event.type" > <xsd:group ref="scxml.event.content" /> <xsd:attributeGroup ref="scxml.event.attlist" /><xsd:complexType name="scxml.raise.type"> <xsd:group ref="scxml.raise.content"/> <xsd:attributeGroup ref="scxml.raise.attlist"/> </xsd:complexType> <xsd:element name="raise" type="scxml.raise.type"/><xsd:element name="event" type="scxml.event.type" /> <!-- log --><!-- log --> <xsd:attributeGroup name="scxml.log.attlist"><xsd:attribute name="label" type="xsd:string" /> <xsd:attribute name="expr" type="xsd:string" use="required" /> <xsd:attribute name="level" type="xsd:positiveInteger" default="1"/><xsd:attribute name="label" type="xsd:string"/> <xsd:attribute name="expr" type="ValueLang.datatype" use="required"/> <xsd:attribute name="level" type="xsd:positiveInteger" default="1"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.log.content"> <xsd:sequence><xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/><xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <xsd:complexType name="scxml.log.type"><xsd:group ref="scxml.log.content" /> <xsd:attributeGroup ref="scxml.log.attlist" /><xsd:group ref="scxml.log.content"/> <xsd:attributeGroup ref="scxml.log.attlist"/> </xsd:complexType> <xsd:element name="log" type="scxml.log.type"/><xsd:element name="log" type="scxml.log.type" /><!-- donedata --> <xsd:attributeGroup name="scxml.donedata.attlist"> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.donedata.mix"> <xsd:choice> <xsd:element ref="content" minOccurs="0" maxOccurs="1"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.donedata.content"> <xsd:sequence> <xsd:group ref="scxml.donedata.mix" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <xsd:complexType name="scxml.donedata.type"> <xsd:group ref="scxml.donedata.content"/> <xsd:attributeGroup ref="scxml.donedata.attlist"/> </xsd:complexType> <xsd:element name="donedata" type="scxml.donedata.type"/> </xsd:schema>
scxml-module-external.xsd
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"><?xml version="1.0" encoding="UTF-8"?> <!-- edited with XMLSpy v2008 sp1 (http://www.altova.com) by Alicia Fraumeni (Genesys Telecommunications Laboratories) --> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:annotation> <xsd:documentation>This is the XML Schema external module for SCXML * sendThis is the XML Schema external module for SCXML * send * cancel * invoke * finalize* param * content The external module defines these elements and their attributes.The external module defines these elements and their attributes.</xsd:documentation> <xsd:documentation source="scxml-copyright.xsd" /></xsd:documentation> <xsd:documentation source="scxml-copyright.xsd"/> </xsd:annotation> <xsd:include schemaLocation="scxml-datatypes.xsd"> <xsd:annotation> <xsd:documentation> This module defines SCXML Attribute DataTypes </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:include schemaLocation="scxml-attribs.xsd"> <xsd:annotation> <xsd:documentation> This module defines Common attributes for SCXML </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:include schemaLocation="scxml-contentmodels.xsd"> <xsd:annotation> <xsd:documentation> This module defines Common content model extensions for SCXML </xsd:documentation> </xsd:annotation> </xsd:include> <!-- send --> <xsd:attributeGroup name="scxml.send.attlist"><xsd:attribute name="event" type="ValueLang.datatype"/> <xsd:attribute name="target" type="ValueLang.datatype" /> <xsd:attribute name="targettype" type="ValueLang.datatype" default="'scxml'" /> <xsd:attribute name="sendid" type="LocLang.datatype" /> <xsd:attribute name="delay" type="ValueLang.datatype" default="'0s'" /> <xsd:attribute name="namelist" type="xsd:string" /> <xsd:attribute name="hints" type="ValueLang.datatype" /><xsd:attribute name="event" type="ValueLang.datatype"/> <xsd:attribute name="target" type="ValueLang.datatype"/> <xsd:attribute name="type" type="ValueLang.datatype" default="'scxml'"/> <xsd:attribute name="id" type="xsd:NMTOKEN"/> <xsd:attribute name="idlocation" type="LocLang.datatype"/> <xsd:attribute name="delay" type="ValueLang.datatype" default="'0s'"/> <xsd:attribute name="timeout" type="ValueLang.datatype" default="'0s'"/> <xsd:attribute name="namelist" type="xsd:string"/> <xsd:attribute name="hints" type="ValueLang.datatype"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.send.mix"> <xsd:choice> <xsd:element ref="content" minOccurs="0" maxOccurs="1"/> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.send.content"> <xsd:sequence><xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/><xsd:group ref="scxml.send.mix" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group><xsd:complexType name="scxml.send.type" > <xsd:group ref="scxml.send.content" /> <xsd:attributeGroup ref="scxml.send.attlist" /><xsd:complexType name="scxml.send.type"> <xsd:group ref="scxml.send.content"/> <xsd:attributeGroup ref="scxml.send.attlist"/> </xsd:complexType> <xsd:element name="send" type="scxml.send.type"/><xsd:element name="send" type="scxml.send.type" /><!-- invoke --> <xsd:attributeGroup name="scxml.invoke.attlist"><xsd:attribute name="src" type="URI.datatype" /> <xsd:attribute name="srcexpr" type="ValueLang.datatype" /> <xsd:attribute name="targettype" type="xsd:NMTOKEN" use="required" /><xsd:attribute name="src" type="ValueLang.datatype"/> <xsd:attribute name="type" type="xsd:NMTOKEN" use="required"/> <xsd:attribute name="id" type="xsd:NMTOKEN"/> <xsd:attribute name="idlocation" type="LocLang.datatype"/> <xsd:attribute name="autoforward" type="Boolean.datatype" use="optional" default="false"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.invoke.mix"> <xsd:choice> <xsd:element ref="finalize" minOccurs="0" maxOccurs="1"/> <xsd:element ref="content" minOccurs="0" maxOccurs="1"/> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.invoke.content"> <xsd:sequence><xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="finalize" minOccurs="0" maxOccurs="1" /> <xsd:element ref="content" minOccurs="0" maxOccurs="1"/> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice><xsd:group ref="scxml.invoke.mix" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group><xsd:complexType name="scxml.invoke.type" > <xsd:group ref="scxml.invoke.content" /> <xsd:attributeGroup ref="scxml.invoke.attlist" /><xsd:complexType name="scxml.invoke.type"> <xsd:group ref="scxml.invoke.content"/> <xsd:attributeGroup ref="scxml.invoke.attlist"/> </xsd:complexType> <xsd:element name="invoke" type="scxml.invoke.type"/><xsd:element name="invoke" type="scxml.invoke.type" /><!-- finalize --> <xsd:attributeGroup name="scxml.finalize.attlist"> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.finalize.mix"> <xsd:choice> <!-- MUST be redefined in the profile in order to define the appropriate executable content and datamodel. --> </xsd:choice> </xsd:group> <xsd:group name="scxml.finalize.content"> <xsd:sequence><xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded" /><xsd:group ref="scxml.finalize.mix" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <xsd:complexType name="scxml.finalize.type"><xsd:group ref="scxml.finalize.content" /> <xsd:attributeGroup ref="scxml.finalize.attlist" /> </xsd:complexType> <xsd:element name="finalize" type="scxml.finalize.type" /> <xsd:attributeGroup name="scxml.param.attlist"> <xsd:attribute name="name" type="xsd:string" use="required" /> <xsd:attribute name="expr" type="ValueLang.datatype" /> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.param.content"> <xsd:sequence> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <xsd:complexType name="scxml.param.type" > <xsd:group ref="scxml.param.content" /> <xsd:attributeGroup ref="scxml.param.attlist" /><xsd:group ref="scxml.finalize.content"/> <xsd:attributeGroup ref="scxml.finalize.attlist"/> </xsd:complexType> <xsd:element name="finalize" type="scxml.finalize.type"/><xsd:element name="param" type="scxml.param.type" /> <!-- content --> <xsd:attributeGroup name="scxml.content.attlist"><!-- cancel --> <xsd:attributeGroup name="scxml.cancel.attlist"> <xsd:attribute name="id" type="ValueLang.datatype" use="required"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup><xsd:group name="scxml.content.content"><xsd:group name="scxml.cancel.content"> <xsd:sequence><xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/><xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group><xsd:complexType name="scxml.content.type" mixed="true"> <xsd:group ref="scxml.content.content" /> <xsd:attributeGroup ref="scxml.content.attlist" /><xsd:complexType name="scxml.cancel.type"> <xsd:group ref="scxml.cancel.content"/> <xsd:attributeGroup ref="scxml.cancel.attlist"/> </xsd:complexType><xsd:element name="content" type="scxml.content.type" /><xsd:element name="cancel" type="scxml.cancel.type"/> </xsd:schema>
scxml-module-data.xsd
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:annotation> <xsd:documentation>This is the XML Schema data module for SCXML * datamodel * dataThis is the XML Schema data module for SCXML * datamodel * data * assign * validateThe anchor module defines these elements and their attributes. </xsd:documentation>* param The anchor module defines these elements and their attributes. </xsd:documentation> <xsd:documentation source="scxml-copyright.xsd"/> </xsd:annotation> <xsd:include schemaLocation="scxml-datatypes.xsd"> <xsd:annotation> <xsd:documentation>This module defines SCXML Attribute DataTypes </xsd:documentation>This module defines SCXML Attribute DataTypes </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:include schemaLocation="scxml-attribs.xsd"> <xsd:annotation> <xsd:documentation>This module defines Common attributes for SCXML </xsd:documentation>This module defines Common attributes for SCXML </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:include schemaLocation="scxml-contentmodels.xsd"> <xsd:annotation> <xsd:documentation> This module defines Common content model extensions for SCXML </xsd:documentation> </xsd:annotation> </xsd:include><!-- datamodel --><!-- datamodel --> <xsd:attributeGroup name="scxml.datamodel.attlist"><xsd:attribute name="schema" type="URI.datatype"/><xsd:attribute name="schema" type="URI.datatype"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.datamodel.content"> <xsd:sequence><xsd:element name="data" minOccurs="0" maxOccurs="unbounded"/> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence><xsd:element ref="data" minOccurs="0" maxOccurs="unbounded"/> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <xsd:complexType name="scxml.datamodel.type"> <xsd:group ref="scxml.datamodel.content"/><xsd:attributeGroup ref="scxml.datamodel.attlist" /><xsd:attributeGroup ref="scxml.datamodel.attlist"/> </xsd:complexType> <xsd:element name="datamodel" type="scxml.datamodel.type"/><xsd:element name="datamodel" type="scxml.datamodel.type" /> <!-- data --><!-- data --> <xsd:attributeGroup name="scxml.data.attlist"><xsd:attribute name="ID" type="xsd:ID" use="required" /> <xsd:attribute name="src" type="URI.datatype" /> <xsd:attribute name="expr" type="ValueLang.datatype" /><xsd:attribute name="id" type="xsd:ID" use="required"/> <xsd:attribute name="src" type="URI.datatype"/> <xsd:attribute name="expr" type="ValueLang.datatype"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.data.content"> <xsd:sequence><xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/><xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <xsd:complexType name="scxml.data.type" mixed="true"><xsd:group ref="scxml.data.content" /> <xsd:attributeGroup ref="scxml.data.attlist" /><xsd:group ref="scxml.data.content"/> <xsd:attributeGroup ref="scxml.data.attlist"/> </xsd:complexType> <xsd:element name="data" type="scxml.data.type"/><!-- assign --><!-- assign --> <xsd:attributeGroup name="scxml.assign.attlist"><xsd:attribute name="location" type="LocLang.datatype" use="required"/> <xsd:attribute name="dataID" type="xsd:IDREF" /> <xsd:attribute name="expr" type="ValueLang.datatype" /><xsd:attribute name="location" type="LocLang.datatype" use="required"/> <xsd:attribute name="dataid" type="xsd:IDREF"/> <xsd:attribute name="expr" type="ValueLang.datatype"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.assign.content"> <xsd:sequence><xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/><xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <xsd:complexType name="scxml.assign.type" mixed="true"><xsd:group ref="scxml.assign.content" /> <xsd:attributeGroup ref="scxml.assign.attlist" /><xsd:group ref="scxml.assign.content"/> <xsd:attributeGroup ref="scxml.assign.attlist"/> </xsd:complexType><xsd:element name="assign" type="scxml.assign.type" /> <!-- validate --><xsd:element name="assign" type="scxml.assign.type"/> <!-- validate --> <xsd:attributeGroup name="scxml.validate.attlist"> <xsd:attribute name="location" type="LocLang.datatype"/><xsd:attribute name="schema" type="URI.datatype" /><xsd:attribute name="schema" type="URI.datatype"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.validate.content"> <xsd:sequence><xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/><xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <xsd:complexType name="scxml.validate.type"><xsd:group ref="scxml.validate.content" /> <xsd:attributeGroup ref="scxml.validate.attlist" /><xsd:group ref="scxml.validate.content"/> <xsd:attributeGroup ref="scxml.validate.attlist"/> </xsd:complexType> <xsd:element name="validate" type="scxml.validate.type"/><xsd:element name="validate" type="scxml.validate.type" /><!-- param --> <xsd:attributeGroup name="scxml.param.attlist"> <xsd:attribute name="name" type="xsd:NMTOKEN" use="required"/> <xsd:attribute name="expr" type="ValueLang.datatype"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.param.content"> <xsd:sequence> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <xsd:complexType name="scxml.param.type"> <xsd:group ref="scxml.param.content"/> <xsd:attributeGroup ref="scxml.param.attlist"/> </xsd:complexType> <xsd:element name="param" type="scxml.param.type"/> </xsd:schema>
scxml-module-script.xsd
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:annotation> <xsd:documentation>This is the XML Schema script module for SCXML * script The script module defines these elements and their attributes.This is the XML Schema script module for SCXML * script The script module defines these elements and their attributes. </xsd:documentation><xsd:documentation source="scxml-copyright.xsd" /><xsd:documentation source="scxml-copyright.xsd"/> </xsd:annotation> <xsd:include schemaLocation="scxml-datatypes.xsd"> <xsd:annotation> <xsd:documentation>Includes common SCXML datatypes </xsd:documentation>Includes common SCXML datatypes </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:include schemaLocation="scxml-attribs.xsd"> <xsd:annotation> <xsd:documentation> Includes common SCXML attributes </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:include schemaLocation="scxml-contentmodels.xsd"> <xsd:annotation> <xsd:documentation> This module defines Common content model extensions for SCXML </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:attributeGroup name="scxml.script.attlist"><xsd:attribute name="src" type="URI.datatype"/> <xsd:attribute name="srcexpr" type="ValueLang.datatype"/> <xsd:attribute name="charset" type="xsd:string"/> <xsd:attributeGroup ref="Cache.attribs"/> <xsd:attributeGroup ref="scxml.extra.attribs"/><!-- Commented out until added to the actual draft. <xsd:attribute name="src" type="URI.datatype"/> <xsd:attribute name="srcexpr" type="ValueLang.datatype"/> <xsd:attribute name="charset" type="xsd:string"/> <xsd:attributeGroup ref="Cache.attribs"/> --> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.script.content"><xsd:sequence> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence><xsd:sequence> <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <xsd:complexType name="scxml.script.type" mixed="true"><xsd:group ref="scxml.script.content" /> <xsd:attributeGroup ref="scxml.script.attlist" /><xsd:group ref="scxml.script.content"/> <xsd:attributeGroup ref="scxml.script.attlist"/> </xsd:complexType><xsd:element name="script" type="scxml.script.type" /><xsd:element name="script" type="scxml.script.type"/> </xsd:schema>
scxml-module-anchor.xsd
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:annotation> <xsd:documentation> This is the XML Schema anchor module for SCXML * anchor The anchor module defines these elements and their attributes. </xsd:documentation><xsd:documentation source="scxml-copyright.xsd" /><xsd:documentation source="scxml-copyright.xsd"/> </xsd:annotation> <xsd:include schemaLocation="scxml-datatypes.xsd"> <xsd:annotation> <xsd:documentation> This module defines SCXML Attribute DataTypes </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:include schemaLocation="scxml-attribs.xsd"> <xsd:annotation> <xsd:documentation> This module defines Common attributes for SCXML </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:include schemaLocation="scxml-contentmodels.xsd"> <xsd:annotation> <xsd:documentation> This module defines Common content model extensions for SCXML </xsd:documentation> </xsd:annotation> </xsd:include> <!-- --> <!-- anchor --> <xsd:attributeGroup name="scxml.anchor.attlist"><xsd:attribute name="type" type="xsd:NMTOKEN" use="required"/> <xsd:attribute name="snapshot" type="LocLang.datatype"/><xsd:attribute name="type" type="xsd:NMTOKEN" use="required"/> <xsd:attribute name="snapshot" type="LocLang.datatype"/> <xsd:attributeGroup ref="scxml.extra.attribs"/> </xsd:attributeGroup> <xsd:group name="scxml.anchor.content"> <xsd:sequence><xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/><xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group><xsd:complexType name="scxml.anchor.type" > <xsd:group ref="scxml.anchor.content" /> <xsd:attributeGroup ref="scxml.anchor.attlist" /><xsd:complexType name="scxml.anchor.type"> <xsd:group ref="scxml.anchor.content"/> <xsd:attributeGroup ref="scxml.anchor.attlist"/> </xsd:complexType><xsd:element name="anchor" type="scxml.anchor.type" /><xsd:element name="anchor" type="scxml.anchor.type"/> <!-- Added this in because it should be defined here and used in the profiles. --> <xsd:simpleType name="Anchor.datatype"> <xsd:annotation> <xsd:documentation> This defines the Anchor data type to be used for the transition element. </xsd:documentation> </xsd:annotation> <xsd:restriction base="xsd:NMTOKEN"/> </xsd:simpleType> </xsd:schema>
scxml-profile-minimum.xsd
<?xml version="1.0" encoding="UTF-8"?><xsd:schema targetNamespace="http://www.w3.org/2005/07/scxml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2005/07/scxml" blockDefault="#all"> <xsd:annotation> <xsd:documentation><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2005/07/scxml" targetNamespace="http://www.w3.org/2005/07/scxml" blockDefault="#all"> <xsd:annotation> <xsd:documentation> This is the XML Schema driver for SCXML 1.0, minimum profile. Please use this namespace for SCXML 1.0 elements: "http://www.w3.org/2005/07/scxml"</xsd:documentation> <xsd:documentation source="scxml-copyright.xsd"/> </xsd:annotation></xsd:documentation> <xsd:documentation source="scxml-copyright.xsd"/> </xsd:annotation><xsd:annotation> <xsd:documentation><xsd:annotation> <xsd:documentation> This is the Schema Driver file for SCXML 1.0, minimum profile This schema + sets the namespace for SCXML 1.0 minimum profile + imports external schemas (xml.xsd) + imports SCXML common datatypes, attributes and common models + imports schema modules SCXML 1.0 includes the following Modules * SCXML core module</xsd:documentation> </xsd:annotation> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"> <xsd:annotation> <xsd:documentation> This import brings in the XML namespace attributes The XML attributes are used by various modules. </xsd:documentation> </xsd:annotation> </xsd:import> <xsd:include schemaLocation="scxml-datatypes.xsd"> <xsd:annotation> <xsd:documentation> This imports brings in the common datatypes </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:include schemaLocation="scxml-attribs.xsd"> <xsd:annotation> <xsd:documentation> This imports brings in the common attributes for SCXML. </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:include schemaLocation="scxml-contentmodels.xsd"> <xsd:annotation> <xsd:documentation> This imports the common content models. </xsd:documentation> </xsd:annotation></xsd:documentation> </xsd:annotation></xsd:include><xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"> <xsd:annotation> <xsd:documentation> This import brings in the XML namespace attributes The XML attributes are used by various modules. </xsd:documentation> </xsd:annotation> </xsd:import><xsd:include schemaLocation="scxml-module-core.xsd"> <xsd:annotation> <xsd:documentation> This imports the core module for SCXML </xsd:documentation> </xsd:annotation> </xsd:include><xsd:include schemaLocation="scxml-datatypes.xsd"> <xsd:annotation> <xsd:documentation> This imports brings in the common datatypes for SCXML </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:include schemaLocation="scxml-attribs.xsd"> <xsd:annotation> <xsd:documentation> This imports brings in the common attributes for SCXML. </xsd:documentation> </xsd:annotation> </xsd:include><!-- Defines the CondLang datatype for this profile. --> <xsd:simpleType name="CondLang.datatype"><xsd:include schemaLocation="scxml-contentmodels.xsd"> <xsd:annotation> <xsd:documentation>Conditional language only consists of In(ID) where ID is the XML ID type identify an SCXML state. The function must evaluate to Boolean True or False. </xsd:documentation>This imports the common content models. </xsd:documentation> </xsd:annotation><xsd:restriction base="xsd:string"/> </xsd:simpleType></xsd:include> <xsd:include schemaLocation="scxml-module-core.xsd"> <xsd:annotation> <xsd:documentation> This imports the core module for SCXML </xsd:documentation> </xsd:annotation> </xsd:include> </xsd:schema>
scxml-profile-ecmascript.xsd
scxml-profile-ecma.xsd
<?xml version="1.0" encoding="UTF-8"?><xsd:schema targetNamespace="http://www.w3.org/2005/07/scxml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2005/07/scxml" xmlns:scxml="http://www.w3.org/2005/07/scxml" blockDefault="#all"> <xsd:annotation> <xsd:documentation> This is the XML Schema driver for SCXML 1.0, ecma profile. Please use this namespace for SCXML 1.0 elements: "http://www.w3.org/2005/07/scxml" </xsd:documentation> <xsd:documentation source="scxml-copyright.xsd"/> </xsd:annotation> <xsd:annotation> <xsd:documentation> This is the Schema Driver file for SCXML 1.0, ecma profile This schema + sets the namespace for SCXML 1.0 basic profile + imports external schemas (xml.xsd) + imports SCXML common datatypes, attributes and content models + imports schema modules SCXML 1.0 includes the following Modules SCXML core module SCXML data module SCXML script module SCXML external module </xsd:documentation> </xsd:annotation> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"> <xsd:annotation> <xsd:documentation> This import brings in the XML namespace attributes The XML attributes are used by various modules. </xsd:documentation> </xsd:annotation> </xsd:import> <xsd:include schemaLocation="scxml-datatypes.xsd"> <xsd:annotation> <xsd:documentation> This imports brings in the common datatypes </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:include schemaLocation="scxml-attribs.xsd"> <xsd:annotation> <xsd:documentation> This imports brings in the common attributes for SCXML. </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:include schemaLocation="scxml-module-data.xsd"> <xsd:annotation> <xsd:documentation> This imports the data module for SCXML </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:include schemaLocation="scxml-module-script.xsd"> <xsd:annotation> <xsd:documentation> This imports the script module for SCXML </xsd:documentation> </xsd:annotation> </xsd:include><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:scxml="http://www.w3.org/2005/07/scxml" xmlns="http://www.w3.org/2005/07/scxml" targetNamespace="http://www.w3.org/2005/07/scxml" blockDefault="#all"> <xsd:annotation> <xsd:documentation> This is the XML Schema driver for SCXML 1.0, ecma profile. Please use this namespace for SCXML 1.0 elements: "http://www.w3.org/2005/07/scxml" </xsd:documentation> <xsd:documentation source="scxml-copyright.xsd"/> </xsd:annotation> <xsd:annotation> <xsd:documentation> This schema + sets the namespace for SCXML 1.0 basic ecma profile + imports external schemas (xml.xsd) + includes SCXML common datatypes, attributes and content models + includes schema modules SCXML 1.0 includes the following Modules SCXML core module SCXML data module SCXML script module SCXML external module </xsd:documentation> </xsd:annotation> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"> <xsd:annotation> <xsd:documentation> This import brings in the XML namespace attributes The XML attributes are used by various modules. </xsd:documentation> </xsd:annotation> </xsd:import> <xsd:include schemaLocation="scxml-datatypes.xsd"> <xsd:annotation> <xsd:documentation> This includes brings in the common data types for SCXML </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:include schemaLocation="scxml-attribs.xsd"> <xsd:annotation> <xsd:documentation> This includes brings in the common attributes for SCXML </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:include schemaLocation="scxml-module-data.xsd"> <xsd:annotation> <xsd:documentation> This includes the data module for SCXML </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:include schemaLocation="scxml-module-script.xsd"> <xsd:annotation> <xsd:documentation> This includes the script module for SCXML </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:redefine schemaLocation="scxml-module-external.xsd"> <xsd:annotation> <xsd:documentation> This imports the external module for SCXML and redefines the following. [1] Redefines send and invoke mix group to allow param [2] Redefines finalize mix group to allow: executable content </xsd:documentation> </xsd:annotation> <xsd:group name="scxml.send.mix"> <xsd:choice> <xsd:group ref="scxml.send.mix"/> <xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.invoke.mix"> <xsd:choice> <xsd:group ref="scxml.invoke.mix"/> <xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.finalize.mix"> <xsd:choice> <xsd:group ref="scxml.finalize.mix"/> <xsd:group ref="scxml.core.executablecontent"/> </xsd:choice> </xsd:group> </xsd:redefine> <xsd:include schemaLocation="scxml-contentmodels.xsd"> <xsd:annotation> <xsd:documentation> This includes the common content models. </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:redefine schemaLocation="scxml-module-core.xsd"> <xsd:annotation> <xsd:documentation> This imports the core module for SCXML and redefines the following. [1] Redefines executable content to allow send, assign, validate, cancel and script elements [2] Redefines state and parallel mix group to allow invoke datamodel [3] Redefines scxml group to allow datamodel script </xsd:documentation> </xsd:annotation> <xsd:group name="scxml.core.executablecontent"> <xsd:choice> <xsd:group ref="scxml.core.executablecontent"/> <xsd:element ref="send"/> <xsd:element ref="assign"/> <xsd:element ref="script"/> <xsd:element ref="validate"/> <xsd:element ref="cancel"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.state.mix"> <xsd:choice> <xsd:group ref="scxml.state.mix"/> <xsd:element ref="invoke" minOccurs="0"/> <xsd:element ref="datamodel" minOccurs="0"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.scxml.mix"> <xsd:choice> <xsd:group ref="scxml.scxml.mix"/> <xsd:element ref="datamodel" minOccurs="0"/> <xsd:element ref="script" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.parallel.mix"> <xsd:choice> <xsd:group ref="scxml.parallel.mix"/> <xsd:element ref="datamodel" minOccurs="0"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.donedata.mix"> <xsd:choice> <xsd:group ref="scxml.donedata.mix"/> <xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.raise.mix"> <xsd:choice> <xsd:group ref="scxml.raise.mix"/> <xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> </xsd:redefine> </xsd:schema><xsd:include schemaLocation="scxml-module-external.xsd"> <xsd:annotation> <xsd:documentation> This imports the external module for SCXML </xsd:documentation> </xsd:annotation> </xsd:include>
scxml-profile-xpath.xsd
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2005/07/scxml" xmlns:scxml="http://www.w3.org/2005/07/scxml" targetNamespace="http://www.w3.org/2005/07/scxml" blockDefault="#all"> <xsd:annotation> <xsd:documentation> This is the XML Schema driver for SCXML 1.0, xpath profile. Please use this namespace for SCXML 1.0 elements:<xsd:group name="scxml.state.mix"> <xsd:choice> <xsd:group ref="scxml.state.mix"/> <xsd:element ref="invoke" minOccurs="0" maxOccurs="1" /> </xsd:choice> </xsd:group>"http://www.w3.org/2005/07/scxml"<xsd:group name="scxml.datamodel.content"> <xsd:sequence> <xsd:choice> <xsd:group ref="scxml.datamodel.content"/> <xsd:element ref="data" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:sequence> </xsd:group> </xsd:redefine></xsd:documentation> <xsd:documentation source="scxml-copyright.xsd"/> </xsd:annotation> <xsd:annotation> <xsd:documentation> This is the Schema Driver file for SCXML 1.0, xpath profile This schema + sets the namespace for SCXML 1.0 basic profile + imports external schemas (xml.xsd) + imports SCXML common datatypes, attributes and content models + imports schema modules SCXML 1.0 includes the following Modules SCXML core module SCXML data module SCXML external module </xsd:documentation> </xsd:annotation><!-- Defines the CondLang datatype for this profile. --> <xsd:simpleType name="CondLang.datatype"><xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"> <xsd:annotation> <xsd:documentation>Conditional language is ECMAScript expression which must evaluate to Boolean True or False. The expression language must define In(stateID) as a valid expression.This import brings in the XML namespace attributes The XML attributes are used by various modules. </xsd:documentation> </xsd:annotation><xsd:restriction base="xsd:string"/> </xsd:simpleType> <!-- Defines the LocLang datatype for this profile. --> <xsd:simpleType name="LocLang.datatype"></xsd:import> <xsd:include schemaLocation="scxml-datatypes.xsd"> <xsd:annotation> <xsd:documentation>Location language is ECMAScript expression identifying a location in the datamodel. </xsd:documentation>This includes brings in the common data types for SCXML </xsd:documentation> </xsd:annotation><xsd:restriction base="xsd:string"/> </xsd:simpleType></xsd:include><!-- Defines the ValueLang datatype for this profile. --> <xsd:simpleType name="ValueLang.datatype"><xsd:include schemaLocation="scxml-attribs.xsd"> <xsd:annotation> <xsd:documentation>Value language is ECMAScript expression return a value.This includes brings in the common attributes for SCXML. </xsd:documentation> </xsd:annotation><xsd:restriction base="xsd:string"/> </xsd:simpleType></xsd:include> <xsd:include schemaLocation="scxml-module-data.xsd"> <xsd:annotation> <xsd:documentation> This includes the data module for SCXML </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:redefine schemaLocation="scxml-module-external.xsd"> <xsd:annotation> <xsd:documentation> This imports the external module for SCXML and redefines the following. [1] Redefines send and invoke mix group to allow param [2] Redefines finalize mix group to allow: executable content </xsd:documentation> </xsd:annotation> <xsd:group name="scxml.send.mix"> <xsd:choice> <xsd:group ref="scxml.send.mix"/> <xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.invoke.mix"> <xsd:choice> <xsd:group ref="scxml.invoke.mix"/> <xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.finalize.mix"> <xsd:choice> <xsd:group ref="scxml.finalize.mix"/> <xsd:group ref="scxml.core.executablecontent"/> </xsd:choice> </xsd:group> </xsd:redefine> <xsd:include schemaLocation="scxml-contentmodels.xsd"> <xsd:annotation> <xsd:documentation> This includes the common content models. </xsd:documentation> </xsd:annotation> </xsd:include> <xsd:redefine schemaLocation="scxml-module-core.xsd"> <xsd:annotation> <xsd:documentation> This imports the core module for SCXML and redefines the following. [1] Redefines executable content to allow send, assign, validate, and cancel elements [2] Redefines state and parallel mix group to allow invoke datamodel [3] Redefines scxml group to allow datamodel </xsd:documentation> </xsd:annotation> <xsd:group name="scxml.core.executablecontent"> <xsd:choice> <xsd:group ref="scxml.core.executablecontent"/> <xsd:element ref="send"/> <xsd:element ref="assign"/> <xsd:element ref="validate"/> <xsd:element ref="cancel"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.state.mix"> <xsd:choice> <xsd:group ref="scxml.state.mix"/> <xsd:element ref="invoke" minOccurs="0"/> <xsd:element ref="datamodel" minOccurs="0"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.scxml.mix"> <xsd:choice> <xsd:group ref="scxml.scxml.mix"/> <xsd:element ref="datamodel" minOccurs="0"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.parallel.mix"> <xsd:choice> <xsd:group ref="scxml.parallel.mix"/> <xsd:element ref="datamodel" minOccurs="0"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.donedata.mix"> <xsd:choice> <xsd:group ref="scxml.donedata.mix"/> <xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.raise.mix"> <xsd:choice> <xsd:group ref="scxml.raise.mix"/> <xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> </xsd:redefine> </xsd:schema>
scxml-profile-xpath.xsd scxml-message.xsd
<?xml version="1.0" encoding="UTF-8"?><xsd:schema targetNamespace="http://www.w3.org/2005/07/scxml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2005/07/scxml" xmlns:scxml="http://www.w3.org/2005/07/scxml" blockDefault="#all"> <xsd:annotation> <xsd:documentation> This is the XML Schema driver for SCXML 1.0, xpath profile. Please use this namespace for SCXML 1.0 elements: "http://www.w3.org/2005/07/scxml" </xsd:documentation> <xsd:documentation source="scxml-copyright.xsd"/> </xsd:annotation> <xsd:annotation> <xsd:documentation> This is the Schema Driver file for SCXML 1.0, xpath profile This schema + sets the namespace for SCXML 1.0 xpath profile + imports external schemas (xml.xsd) + imports SCXML common datatypes, attributes and content models + imports schema modules SCXML 1.0 includes the following Modules SCXML core module SCXML data module SCXML external module </xsd:documentation> </xsd:annotation><!-- XML Schema for sending messages to SCXML processors. --> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:scxml="http://www.w3.org/2005/07/scxml" targetNamespace="http://www.w3.org/2005/07/scxml" elementFormDefault="qualified"><xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"> <xsd:annotation> <xsd:documentation> This import brings in the XML namespace attributes The XML attributes are used by various modules. </xsd:documentation> </xsd:annotation> </xsd:import><xsd:annotation> <xsd:documentation xml:lang="en"> XML Schema for sending messages to SCXML processors. Version 1.0 </xsd:documentation> <xsd:documentation source="scxml-copyright.xsd" /> </xsd:annotation><xsd:include schemaLocation="scxml-datatypes.xsd"> <xsd:annotation> <xsd:documentation> This imports brings in the common datatypes </xsd:documentation> </xsd:annotation> </xsd:include><xsd:attributeGroup name="scxmlmessage.extra.attribs"> <xsd:annotation> <xsd:documentation> Group allowing attributes from other namespaces </xsd:documentation> </xsd:annotation> <xsd:anyAttribute namespace="##other" processContents="lax" /> </xsd:attributeGroup><xsd:include schemaLocation="scxml-attribs.xsd"> <xsd:annotation> <xsd:documentation> This imports brings in the common attributes for SCXML. </xsd:documentation> </xsd:annotation> </xsd:include><xsd:attributeGroup name="scxmlmessage.message.attlist"> <xsd:attribute name="version" type="xsd:string" fixed="1.0" use="required" /> <xsd:attribute name="source" type="xsd:anyURI" use="required" /> <xsd:attribute name="target" type="xsd:anyURI" use="required" /> <xsd:attribute name="sendid" type="xsd:string" use="optional"> <xsd:annotation> <xsd:documentation> Non SCXML senders are not required to specify a sendid </xsd:documentation> </xsd:annotation> </xsd:attribute> <xsd:attribute name="name" type="xsd:string" use="optional"> <xsd:annotation> <xsd:documentation> Defaults to "external.event" </xsd:documentation> </xsd:annotation> </xsd:attribute> <xsd:attribute name="sourcetype" type="xsd:string" use="optional"> <xsd:annotation> <xsd:documentation> Defaults to "scxml" </xsd:documentation> </xsd:annotation> </xsd:attribute> <xsd:attribute name="type" type="xsd:string" use="optional"> <xsd:annotation> <xsd:documentation> Defaults to "scxml" </xsd:documentation> </xsd:annotation> </xsd:attribute> <xsd:attribute name="language" type="xsd:string" use="optional"> <xsd:annotation> <xsd:documentation> Defaults to "xml" </xsd:documentation> </xsd:annotation> </xsd:attribute> <xsd:attributeGroup ref="scxml:scxmlmessage.extra.attribs" /> </xsd:attributeGroup><xsd:include schemaLocation="scxml-module-data.xsd"> <xsd:annotation> <xsd:documentation> This imports the data module for SCXML </xsd:documentation> </xsd:annotation> </xsd:include><xsd:group name="scxmlmessage.message.content"> <xsd:sequence> <xsd:element ref="scxml:payload" minOccurs="1" maxOccurs="1" /> </xsd:sequence> </xsd:group><xsd:include schemaLocation="scxml-module-external.xsd"> <xsd:annotation> <xsd:documentation> This imports the external module for SCXML </xsd:documentation> </xsd:annotation> </xsd:include><xsd:complexType name="scxmlmessage.message.type"> <xsd:group ref="scxml:scxmlmessage.message.content" /> <xsd:attributeGroup ref="scxml:scxmlmessage.message.attlist" /> </xsd:complexType> <xsd:element name="message" type="scxml:scxmlmessage.message.type" /><xsd:redefine schemaLocation="scxml-contentmodels.xsd"> <xsd:annotation> <xsd:documentation> This imports the common content models. </xsd:documentation> </xsd:annotation> </xsd:redefine> <xsd:redefine schemaLocation="scxml-module-core.xsd"> <xsd:annotation> <xsd:documentation> This imports the core module for SCXML. [1] Redefines executable content to allow send, assign and validate elements [2] Redefines state element to allow invoke and datamodel [3] Redefines scxml element allow datamodel element [4] Redefines parallel element to allow datamodel element </xsd:documentation> </xsd:annotation><xsd:attributeGroup name="scxmlmessage.payload.attlist"> <xsd:attributeGroup ref="scxml:scxmlmessage.extra.attribs" /> </xsd:attributeGroup><xsd:group name="scxml.core.executablecontent"> <xsd:choice> <xsd:group ref="scxml.core.executablecontent"/> <xsd:element ref="send"/> <xsd:element ref="assign"/> <xsd:element ref="validate"/> </xsd:choice><xsd:group name="scxmlmessage.payload.content"> <xsd:sequence> <xsd:element ref="scxml:hint" minOccurs="0" maxOccurs="1" /> <xsd:choice> <xsd:sequence> <xsd:element ref="scxml:property" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence> <xsd:sequence> <xsd:any namespace="##other" minOccurs="1" maxOccurs="unbounded" processContents="lax" /> </xsd:sequence> </xsd:choice> </xsd:sequence> </xsd:group><xsd:group name="scxml.state.mix"> <xsd:choice> <xsd:group ref="scxml.state.mix"/> <xsd:element ref="invoke" minOccurs="0" maxOccurs="1" /> <xsd:element ref="datamodel" minOccurs="0" maxOccurs="1" /> </xsd:choice> </xsd:group><xsd:group name="scxml.scxml.content"> <xsd:sequence> <xsd:choice minOccurs="0" maxOccurs="unbounded" > <xsd:group ref="scxml.scxml.content"/> <xsd:element ref="datamodel" minOccurs="0" maxOccurs="1"/> </xsd:choice> </xsd:sequence> </xsd:group> <xsd:group name="scxml.parallel.content"> <xsd:sequence> <xsd:choice minOccurs="0" maxOccurs="unbounded" > <xsd:group ref="scxml.parallel.content"/> <xsd:element ref="datamodel" minOccurs="0" maxOccurs="1"/> </xsd:choice> </xsd:sequence> </xsd:group> </xsd:redefine><xsd:complexType name="scxmlmessage.payload.type"> <xsd:group ref="scxml:scxmlmessage.payload.content" /> <xsd:attributeGroup ref="scxml:scxmlmessage.payload.attlist" /> </xsd:complexType> <xsd:element name="payload" type="scxml:scxmlmessage.payload.type" /> <xsd:attributeGroup name="scxmlmessage.property.attlist"> <xsd:attribute name="name" type="xsd:string" use="required" /> <xsd:attributeGroup ref="scxml:scxmlmessage.extra.attribs" /> </xsd:attributeGroup><!-- Defines the CondLang datatype for this profile. --> <xsd:simpleType name="CondLang.datatype"> <xsd:annotation> <xsd:documentation> Conditional language is XPath expression which must evaluate to Boolean True or False. The expression language must define In(stateID) as a valid expression. </xsd:documentation> </xsd:annotation> <xsd:restriction base="xsd:string"/> </xsd:simpleType><xsd:group name="scxmlmessage.property.content"> <xsd:sequence> <xsd:element ref="scxml:hint" minOccurs="0" maxOccurs="1" /> <xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="skip" /> </xsd:sequence> </xsd:group><!-- Defines the LocLang datatype for this profile. --> <xsd:simpleType name="LocLang.datatype"> <xsd:annotation> <xsd:documentation> Location language is XPath expression identifying a location in the datamodel. </xsd:documentation> </xsd:annotation> <xsd:restriction base="xsd:string"/> </xsd:simpleType><xsd:complexType name="scxmlmessage.property.type" mixed="true"> <xsd:group ref="scxml:scxmlmessage.property.content" /> <xsd:attributeGroup ref="scxml:scxmlmessage.property.attlist" /> </xsd:complexType><!-- Defines the ValueLang datatype for this profile. --> <xsd:simpleType name="ValueLang.datatype"> <xsd:annotation> <xsd:documentation> Value language is XPath expression returning a value. </xsd:documentation> </xsd:annotation> <xsd:restriction base="xsd:string"/> </xsd:simpleType><xsd:element name="property" type="scxml:scxmlmessage.property.type" /> <xsd:element name="hint" type="xsd:string" /> </xsd:schema>
This SCXML document gives an overview of the SCXML language and shows the use of its state machine transition flows:
<?xml version="1.0" encoding="us-ascii"?> <!-- A wrapper state that contains all other states in this file- it represents the complete state machine --> <scxml xmlns="http://www.w3.org/2005/07/scxml"- it represents the complete state machine --> <scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0"initial="Main">initial="Main" profile="ecmascript"> <state id="Main"> <!-- its initial state is Test1 --> <initial> <transition target="Test1"/> </initial> <!-- Really simple state showing the basic syntax. --> <state id="Test1"> <initial> <transition target="Test1Sub1"/> </initial> <!-- Runs before we go into the substate --> <onentry> <log expr="'Inside Test1'"/> </onentry> <!-- Here is our first substate --> <state id="Test1Sub1"> <onentry> <log expr="'Inside Test1Sub1.'"/> </onentry> <onexit> <log expr="'Leaving Test1Sub1'"/> </onexit> <!-- Go to Sub2 on Event1 --> <transition event="Event1" target="Test1Sub2"/> </state> <!-- Here is the second substate It is final, so Test1 is done when we get here --> <final id="Test1Sub2"/> <!-- We get this event when we reach Test1Sub2. --> <transition event="Test1.done" target="Test2"/> <!-- We run this on the way out of Test1 --> <onexit> <log expr="'Leaving Test1...'"/> </onexit> </state> <state id="Test2"> <initial> <transition target="Test2Sub1"/> </initial> <!-- This time we reference a state defined in an external file. Note that we could have loaded the entire file by leaving off the #Test2Sub1, but in that case we would need to rename one of the Test2Sub1 states (here or in the external file) to avoid the name collision --> <state id="Test2Sub1" src="External.scxml#Test2Sub1"/> <final id="Test2Sub2"/> <!-- Test2Sub2 is defined as final, so this event is generated when we reach it --> <transition event="Test2.done" next="Test3"/> </state> <state id="Test3"> <initial> <transition target="Test3Sub1"/> </initial> <state id="Test3Sub1"> <onentry> <log expr="'Inside Test3Sub1...'"/> <!-- Send our self an event in 5s --><send event="Timer" delay="5s"/><send event="'Timer'" delay="'5s'"/> </onentry> <!-- Transition on to Test4. This will exit both us and our parent. --> <transition event="Timer" target="Test4"/> <onexit> <log expr="'Leaving Test3Sub1...'"/> </onexit> </state> <onexit> <log expr="'Leaving Test3...'"/> </onexit> </state> <state id="Test4"> <onentry> <log expr="'Inside Test4...'"/> </onentry> <initial> <transition target="Test4Sub1"/> </initial> <state id="Test4Sub1"> <onexit> <log expr="'Leaving Test4Sub1...'"/> </onexit> <!-- This transition causes the state to exit immediately after entering Test4Sub1. The transition has no event or guard so it is always active --> <transition target="Test5"/> </state> </state> <state id="Test5"> <onentry> <log expr="'Inside Test5...'"/> </onentry> <initial> <transition target="Test5P"/> </initial> <!-- Fire off our parallel states --> <parallel id="Test5P"> <final id="Test5PSub1"/> <final id="Test5PSub2"/> <onexit> <log expr="'all parallel states done'"/> </onexit> </parallel> <!-- The parallel states are all final, so this event is generated immediately. Although not shown, compound states (i.e., <state>s with content) are permitted within <parallel> as well. --> <transition event="Test5P.done" target="Test6"/> </state> <!-- - This state shows invocation of an external component. - We will use CCXML + VoiceXML actions as an example - as it is a good smoke test to show how it all - fits together. - Note: In a real app you would likely - split this over several states but we - are trying to keep it simple here. --> <state id="Test6" xmlns:ccxml="http://www.w3.org/2002/09/ccxml" xmlns:v3="http://www.w3.org/2005/07/vxml3"> <datamodel> <data name="ccxmlid" expr="32459"/> <date name="v3id" expr="17620"/> <data name="dest" expr="'tel:+18315552020'"/> <data name="src" expr="'helloworld2.vxml'"/> <data name="id" expr="'HelloWorld'"/> </datamodel> <onentry> <!-- Use <send> to run a createcall using the CCXML component / Event I/O Processor --><send target="ccxmlid" targettype="ccxml" event="ccxml:createcall" namelist="dest"/><send target="ccxmlid" type="'ccxml'" event="'ccxml:createcall'" namelist="dest"/> </onentry> <transition event="ccxml:connection.connected"> <!-- Here as a platform-specific extension we use example V3 Custom Action Elements instead of send. --> <v3:form id="HelloWorld"> <v3:block><v3:prompt>Hello World!</v3:prompt></v3:block> </v3:form> </transition> <transition event="v3:HelloWorld.done"> <!-- Here we are using the low level <send> element to run a v3 form. Note that the event "v3:HelloWorld.done" is assumed either to be set/sent explicitly by the v3:form code or implicitly by some process outside of the v3:form --><send target="v3id" targettype="v3" event="v3:formstart" namelist="src id"/><send target="v3id" type="'v3'" event="'v3:formstart'" namelist="src id"/> </transition> <transition event="v3:HelloWorld2.done"> <!-- we use _eventdata to access data in the event we're processing. Again we assume the v3:HelloWorld2.done is set/sent from outside this document --> <ccxml:disconnect connectionid="_eventdata.connectionid"/> </transition> <transition event="ccxml:connection.disconnected" target="Done"/> <!-- Now some transitions to handle events generated by the component --> <transition event="send.successful"> <!-- Component invoked successfully. This transition has no target so Test6 is not exited. We are just going to log that we were able to send an event. --> <log expr="'Event was able to be sent'"/> </transition> <transition event="error.send" target="Done"> <!-- If we get an error event we move to the Done state that is a final state. --> <log expr="'Sending to and External component failed'"/> </transition> <onexit> <log expr="'Finished with external component'"/> </onexit> </state> <!-- This final state is an immediate child of Main - when we get here, Main.done is generated. --> <final id="Done"/> <!-- End of Main > --> </state> </scxml>
<?xml version="1.0" encoding="us-ascii"?><scxml version="1.0" xmlns="http://www.w3.org/2005/07/scxml" initialstate="Test2Sub1"><scxml version="1.0" xmlns="http://www.w3.org/2005/07/scxml" initial="Test2Sub1"> <!-- - This is an example substate defined in - an external file referenced by Main.scxml. --> <state id="Test2Sub1"> <onentry> <log expr="'Inside Test2Sub1'"/> </onentry> <transition event="Event2" target="Test2Sub2"/> </state> </scxml>
The example below, which is from the Apache Shale Project. Shale is a web application framework based on JavaServer Faces (JSF). It's composed of loosely coupled services that provide functionality such as application event callbacks, dialogs with conversation-scoped state, a view technology called Clay, annotation-based functionality to reduce configuration requirements and support for remoting. For more information on Shale please see http://shale.apache.org/ . SCXML is used as a "dialog manager" service in Shale (for details on the integration of SCXML in Shale please see http://shale.apache.org/shale-dialog-scxml/index.html ). It allows Shale application authors to express navigation across multiple JSF views and/or other conversations with users of a JSF application using the SCXML markup notation. The example below describes how the navigation across multiple JSF views can be expressed using SCXML. It also shows how a submachine (edit-profile-config.scxml) can be used within an SCXML file. The binding language used in these examples is EL [EL] , which is the expression language supported in the JSF environment.
<?xml version="1.0" encoding="UTF-8"?> <!-- Dialog definitions for Shale Use Cases Example Web Application written out as SCXML to demonstrate use of Commons SCXML as one of Shale's Dialog Manager implementations. For details, see: http://shale.apache.org/shale-dialog-scxml/ --><scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:my="http://scxml.example.org/"<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:my="http://scxml.examples.org/" version="1.0" initial="checkCookie" profile="el" > <state id="checkCookie"> <onentry> <my:var name="cookieOutcome" expr="#{profile$logon.check}" /> </onentry> <transition cond="${cookieOutcome eq 'authenticated'}" target="exit"/> <transition cond="${cookieOutcome eq 'unauthenticated'}" target="logon"/> </state> <state id="logon"> <transition event="faces.outcome" cond="${outcome eq 'authenticated'}" target="exit"/> <transition event="faces.outcome" cond="${outcome eq 'create'}" target="createProfile"/> </state> <state id="createProfile" src="edit-profile-config.xml" > <transition event="createProfile.done" cond="${outcome eq 'success' or outcome eq 'cancel'}" target="exit"/> </state> <final id="exit"/> </scxml>
<?xml version="1.0" encoding="UTF-8"?> <!-- Dialog definitions for Shale Use Cases Example Web Application written out as SCXML to demonstrate use of Commons SCXML as one of Shale's Dialog Manager implementations. For details, see: http://shale.apache.org/shale-dialog-scxml/ --><scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:my="http://scxml.example.org/"<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:my="http://scxml.examples.org/" version="1.0" initial="edit" profile="el"> <state id="edit"> <initial> <transition target="setup"/> </initial> <!-- global transitions (within state "edit") --> <transition event="faces.outcome" cond="${outcome eq 'cancel'}" target="cancel"/> <transition event="faces.outcome" cond="${outcome eq 'finish'}" target="finish"/> <state id="setup"> <onentry> <my:var name="setupOutcome" expr="#{profile$edit.setup}" /> </onentry> <transition cond="${setupOutcome eq 'success'}" target="page1"/> </state> <state id="page1"> <transition event="faces.outcome" cond="${outcome eq 'next'}" target="page2"/> </state> <state id="page2"> <transition event="faces.outcome" cond="${outcome eq 'previous'}" target="page1"/> <transition event="faces.outcome" cond="${outcome eq 'next'}" target="page3"/> </state> <state id="page3"> <transition event="faces.outcome" cond="${outcome eq 'previous'}" target="page2"/> <transition event="faces.outcome" cond="${outcome eq 'next'}" target="editExit"/> </state> </state> <state id="cancel"> <onentry> <my:var name="cancelOutcome" expr="#{profile$edit.cancel}" /> </onentry> <transition cond="${cancelOutcome eq 'success'}" target="editExit"> <my:var name="outcome" expr="cancel"/> </transition> </state> <state id="finish"> <onentry> <my:var name="finishOutcome" expr="#{profile$edit.finish}" /> </onentry> <transition cond="${finishOutcome eq 'username'}" target="page1"/> <transition cond="${finishOutcome eq 'password'}" target="page1"/> <transition cond="${finishOutcome eq 'success'}" target="editExit"> <my:var name="outcome" expr="success"/> </transition> </state> <final id="editExit"/> </scxml>
The following two SCXML documents demonstrate the use of Invoke and finalize. The first example shows the control flow for a voice portal offering traffic reports.
<?xml version="1.0"?> <?access-control allow="*"?> <scxml version="1.0" initial="Intro" profile="ecmascript"> <state id="Intro"><invoke src="dialog.vxml#Intro" targettype="vxml2"/><invoke src="dialog.vxml#Intro" type="vxml2"/> <transition event="success" cond="_data.sessionChrome.playAds" target="PlayAds"/> <transition event="success" cond="!_data.sessionChrome.playAds && _data.ANIQuality" target="ShouldGoBack"/> <transition event="success" cond="!_data.sessionChrome.playAds && !_data.ANIQuality" target="StartOver"/> </state> <state id="PlayAds"><invoke src="dialog.vxml#PlayAds" targettype="vxml2"/><invoke src="dialog.vxml#PlayAds" type="vxml2"/> <transition event="success" cond="_data.ANIQuality" target="ShouldGoBack"/> <transition event="success" cond="!_data.ANIQuality" target="StartOver"/> </state> <state id="StartOver"> <onenter> <script>enterStartOver();</script> </onenter><invoke src="dialog.vxml#StartOver" targettype="vxml2"><invoke src="dialog.vxml#StartOver" type="vxml2"> <param name="gotItFromANI" expr="_data.gotItFromANI"/> <finalize> <script>finalizeStartOver();</script> </finalize> </invoke> <transition event="success" target="ShouldGoBack"/> <transition event="doOver" target="StartOver"/> <transition event="restart" target="Intro"/> <!-- bail out to caller --> </state> <state id="ShouldGoBack"><invoke src="dialog.vxml#ShouldGoBack" targettype="vxml2"><invoke src="dialog.vxml#ShouldGoBack" type="vxml2"> <param name="cityState" expr="_data.cityState"/> <param name="gotItFromANI" expr="_data.gotItFromANI"/> <finalize> <script>finalizeShouldGoBack();</script> </finalize> </invoke> <transition event="highWay" target="HighwayReport"/> <transition event="go_back" target="StartOver"/> <transition event="doOver" target="ShouldGoBack"/> <transition event="restart" target="Intro"/> </state> <state id="HighwayReport"><invoke src="dialog.vxml#HighwayReport" targettype="vxml2"><invoke src="dialog.vxml#HighwayReport" type="vxml2"> <param name="cityState" expr="_data.cityState"/> <param name="gotItFromANI" expr="_data.gotItFromANI"/> <param name="playHRPrompt" expr="_data.playHRPrompt"/> <param name="metroArea" expr="_data.metroArea"/> <finalize> <script>finalizeHighwayReport();</script> </finalize> </invoke> <transition event="highway" target="PlayHighway"/> <transition event="go_back" target="StartOver"/> <transition event="doOver" target="HighwayReport"/> <transition event="fullreport" target="FullReport"/> <transition event="restart" target="Intro"/> </state> <state id="FullReport"><invoke src="dialog.vxml#FullReport" targettype="vxml2"><invoke src="dialog.vxml#FullReport" type="vxml2"> <param name="cityState" expr="_data.cityState"/> <param name="metroArea" expr="_data.metroArea"/> <finalize> <script>finalizeFullReport();</script> </finalize> </invoke> <transition event="go_back" target="HighwayReport"/> <transition event="new_city" target="StartOver"/> </state> <state id="PlayHighway"><invoke src="dialog.vxml#PlayHighway" targettype="vxml2"><invoke src="dialog.vxml#PlayHighway" type="vxml2"> <param name="cityState" expr="_data.cityState"/> <param name="curHighway" expr="_data.curHighway"/> <finalize> <script>finalizePlayHighway();</script> </finalize> </invoke> <transition event="go_back" target="HighwayReport"/> </state> </scxml>
The following example shows a the control flow for a blackjack game.
<?xml version="1.0"?> <?access-control allow="*"?> <scxml version="1.0" profile="ecmascript" initial="master"> <state id="master"> <initial id="init1"> <transition target="_home"/> </initial> <transition event="new_dealer" target="NewDealer"/> <transition event="mumble" target="_home"/> <!-- bail out to caller --> <transition event="silence" target="_home"/> <!-- bail out to caller --> <state id="_home"> <onenter> <script> _data = {}; </script> </onenter><invoke src="datamodel.v3#InitDataModel" targettype="vxml3"><invoke src="datamodel.v3#InitDataModel" type="vxml3"> <finalize> <script> var n; for (n in event) { _data[n] = event[n]; } </script> </finalize> </invoke> <transition event="success" target="Welcome"/> </state> <state id="Welcome"><invoke src="dialog.vxml#Welcome" targettype="vxml3"><invoke src="dialog.vxml#Welcome" type="vxml3"> <param name="skinpath" expr="_data.skinpath"/> </invoke> <transition event="success" target="Intro2"/> </state> <state id="Intro2"><invoke src="dialog.vxml#Intro2" targettype="vxml3"><invoke src="dialog.vxml#Intro2" type="vxml3"> <param name="skinpath" expr="_data.skinpath"/> </invoke> <transition event="success" target="EvalDeal"/> </state> <state id="EvalDeal"> <onenter> <script>enterEvalDeal();</script> </onenter><invoke src="dialog.vxml#EvalDeal" targettype="vxml3"><invoke src="dialog.vxml#EvalDeal" type="vxml3"> <param name="skinpath" expr="_data.skinpath"/> <param name="playercard1" expr="_data.playercard1"/> <param name="playercard2" expr="_data.playercard2"/> <param name="playertotal" expr="_data.blackjack.GetTotalOf('caller').toString()"/> <param name="dealercardshowing" expr="_data.dealercardshowing"/> </invoke> <transition event="success" target="AskHit"/> </state> <state id="AskHit"><invoke src="dialog.vxml#AskHit" targettype="vxml3"><invoke src="dialog.vxml#AskHit" type="vxml3"> <param name="skinpath" expr="_data.skinpath"/> <finalize> <script>finalizeAskHit();</script> </finalize> </invoke> <transition event="hit" target="PlayNewCard"/> <transition event="stand" target="PlayDone"/> </state> <state id="PlayNewCard"><invoke src="dialog.vxml#PlayNewCard" targettype="vxml3"><invoke src="dialog.vxml#PlayNewCard" type="vxml3"> <param name="skinpath" expr="_data.skinpath"/> <param name="playernewcard" expr="_data.playernewcard"/> <param name="playertotal" expr="_data.blackjack.GetTotalOf('caller').toString()"/> </invoke> <transition event="success" cond="_data.blackjack.GetTotalOf('caller') >= 21" target="PlayDone"/> <transition event="success" target="AskHit"/> <!-- less than 21 --> </state> <state id="PlayDone"> <onenter> <script>enterPlayDone();</script> </onenter><invoke src="dialog.vxml#PlayDone" targettype="vxml3"><invoke src="dialog.vxml#PlayDone" type="vxml3"> <param name="skinpath" expr="_data.skinpath"/> <param name="gameresult" expr="_data.blackjack.GetGameResult()"/> <param name="dealertotal" expr="_data.blackjack.GetTotalOf('dealer').toString()"/> </invoke> <transition event="playagain" target="Intro2"/> <transition event="quit" target="_home"/> </state> <state id="NewDealer"> <onenter> <script>enterNewDealer();</script> </onenter><invoke src="dialog.vxml#Dummy" targettype="vxml3"/><invoke src="dialog.vxml#Dummy" type="vxml3"/> <transition event="success" target="Welcome"/> </state> </state> </scxml>
Custom Action Elements can be defined in other specifications/namespaces and are responsible for performing actions on behalf of custom components. Logically Custom Action Elements can be thought of as a collection of actions and handlers to perform specific tasks. An example of this is a CCXML <accept> element that is a Custom Action Element:
<transition event="ccxml:connection.alerting"> <ccxml:accept connectionid="eventdata.connectionid"/> </transition>
This could be written using a <send> element using the following syntax:
<datamodel> <data name="connectionid"/> </datamodel> <transition event="ccxml:connection.alerting"> <assign name="connectionid" expr="eventdata.connectionid"/><send targettype="ccxml" event="ccxml:accept" namelist="connectionid"/><send type="'ccxml'" event="'ccxml:accept'" namelist="connectionid"/> </transition>
A more complicated example might be a CCXML <createcall> where you are both providing variables and getting values back that using only the <send> syntax would be more complex as it would need to be broken over several steps. For example:
<onentry> <ccxml:createcall dest="'tel:+18315552020'" connectionid="myConnectionID"/> </onentry>
Would need to be modeled in two steps using <send> as you would need to do something like the following:
<datamodel> <data name="dest" expr="'tel:+18315552020'"/> <data name="connectionid"/> </datamodel> <onentry><send targettype="ccxml" event="ccxml:createcall" namelist="dest"/><send type="'ccxml'" event="'ccxml:createcall'" namelist="dest"/> </onentry> <transition event="ccxml:createcall.success"> <assign name="connectionid" expr="eventdata.connectionid"/> </transition>
The exact mappings between Custom Action Elements and <send> actions are to be defined in the individual Custom Action Element specifications.
A SCXML 1.0 processor is a user agent that can parse and process Conforming SCXML 1.0 documents.
In a Conforming SCXML 1.0 Processor, the XML parser must be able to parse and process all well-formed XML constructs defined within [XML] and [XMLNames] . It is not required that a Conforming SCXML 1.0 processor use a validating parser.
Conformance in SCXML is defined with respect to profiles. A Conforming SCXML 1.0 Processor that supports a given profile must support the syntax and semantics of all SCXML elements in that profile as described in this document. Consequently, a SCXML 1.0 Processor must not throw an error.unsupported.<element> for any SCXML element in that profile when processing a Conforming SCXML 1.0 Document.
When a Conforming SCXML 1.0 Processor encounters a Conforming SCXML 1.0 Document with non-SCXML elements or attributes which are proprietary, or defined in a non-SCXML namespace, and which cannot be processed, the processor's behavior is defined by the value of the 'exmode' attribute in the root <scxml> element of the document. If 'exmode' is strict, the processor must throw an error.badfetch event. If 'exmode' is 'lax', the processor must ignore the element.
When a Conforming SCXML 1.0 Processor encounters a document with a root element designating a namespace other than SCXML, its behavior is undefined.
When a conforming SCXML 1.0 Processor encounters a document with a root element of <scxml> with a version attribute with a value other than 1.0, its behavior is undefined.
There is, however, no conformance requirement with respect to performance characteristics of the SCXML 1.0 Processor.
The SCXML Event I/O Processor is intended to transport messages in a specific format to and from SCXML sessions. This processor specifies the schema of the messages and how they map onto SCXML events, but it does not define the transport mechanism, which is platform-specific. The schema for the message is available at D.10 SCXML Message Schema :.The sender or the receiver of the message may be either an SCXML session or an external entity, but this specification defines the behavior for SCXML sessions only .
The contents of the individual messages are defined as follows:
The mapping between <send>, the SCXML message structure, and the event that is raised in the receiving session is given below.
<send> element | SCXML Message Structure | Target Session Event |
---|---|---|
'event' attribute | 'name' attribute | 'name' field |
not present in <send> but known to platform | 'source' attribute | 'origin' field |
'target' attribute | 'target' attribute | not present |
literal provided by author or value generated by platform | 'sendid' attribute | 'sendid' field |
not present | 'sourcetype' attribute. Always "scxml". | 'origintype' field. Always "scxml". |
not present | 'language' attribute. | not present |
'namelist' attribute, <content> child, or <param> children | <payload> element | data field |
The sending SCXML Event I/O processor MUST populate these fields of the SCXML message structure in the manner defined above, and the receiving processor MUST use them to create the appropriate internal or external event structure as defined above.
When an SCXML processor receives a message via the SCXML Event I/O Processor it validates the syntax of the incoming message and checks that it matches an active session. If the message fails syntactic validation or does not match an active session, the receiving processor notifies the sending processor of the error and ignores the message. If the message passes validation, but the receiving processor cannot handle the data format contained in the message, the receiving processor SHOULD raise the error: error.receive.datamismatch in the session for which the message was intended and SHOULD also notify the sending processor of the error. It then ignores the message. If no errors occur, the receiving session converts the message into an SCXML event, using the mapping defined above, and inserts the event its external event queue.
If the sending entity is an SCXML session, it SHOULD also report errors. If the sending session specifies a sessionid that does not exist on the receiving system, it SHOULD raise the error: error.send.nosuchsession. If the sending session specifies a data format that the receiving session does not support, it SHOULD raise the error: error.send.datamismatch. For any other errors, such as inability to connect to the receiving system, the sending system SHOULD raise error.send.failed.scxmlio. An implementation may extend any of the errors described in this section to provide more information if it desires. For example, an implmentation may choose to raise error.send.failed.scxmlio.cannotconnect or error.receive.datamismatch.ecmascript, etc.
The SCXML Event I/O Processor MUST handle the 'cancel.invoke. invokeid ' event. In particular, if SCXML session session1 sends this event to session session2, where session1 invoked session2 via an <invoke> element with invokeid invokeid ,the SCXML Event I/O Processor MUST set the 'continue' variable in session2 to 'false' and discard the event. (See B Algorithm for SCXML Interpretation for details.) In all other cases (that is, in cases where the invokeid does not match), the SCXML Event I/O processor MUST discard the event and SHOULD signal an error.
Here are some examples of SCXML messages sent between SCXML sessions. Each example shows the original <send> element, the corresponding <message> structures and a transition handling the resulting event in the receiving SCXML session.
EXAMPLE 1: First, here is a message with an XML payload generated by <send> with a 'namelist':
SESSION1 : SENDING SESSION Pattern: "event" attribute with an optional "namelist" <datamodel> <data id="email" expr="'mailto:recipient@example.com'"/> <data id="content" expr="'http://www.example.com/mycontent.txt'"/> <data id="xmlcontent"> <headers xmlns="http://www.example.com/headers"> <cc>archive@example.com</cc> <subject>Example email</subject> </headers> </data> </datamodel> ... <send id="send-123" target="'http://scxml-processors.example.com/session2'" type="'scxml'" event="'email.send'" namelist="email content xmlcontent" hints="'Email headers'"/>
Here is the actual XML message that will be sent over platform-specific transport and converted into an event in the target SCXML session:
<scxml:message xmlns:scxml="http://www.w3.org/2005/07/scxml" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2005/07/scxml scxml-message.xsd" source="http://scxml-processors.example.com/session1" sourcetype="scxml" target="http://scxml-processors.example.com/session2" type="scxml" sendid="send-123" name="email.send"> <scxml:payload> <scxml:property name="email">mailto:recipient@example.com</scxml:property> <scxml:property name="content">http://www.example.com/mycontent.txt</scxml:property> <scxml:property name="xmlcontent"> <scxml:hint>Email headers</scxml:hint> <headers xmlns="http://www.example.com/headers"> <cc>archive@example.com</cc> <subject>Example email</subject> </headers> </scxml:property> </scxml:payload> </scxml:message>
Here is sample SCXML code to process that event in the receiving SCXML session. In this example <my:email> is platform-specific executable content that sends an email:
SESSION2 : RECEIVING SESSION Pattern: "event" attribute with an optional "namelist" <scxml:transition event="email.send"> <my:email to="data('_event')/scxml:property[@name='email']" cc="data('_event')/scxml:property[@name='xmlcontent']/h:headers/h:cc" subject="data('_event')/scxml:property[@name='xmlcontent']/h:headers/h:subject" content="data('_event')/scxml:property[@name='content']"/> </scxml:transition>
EXAMPLE 2: The next example shows <send> using inline XML content:
SESSION1 : SENDING SESSION Pattern: "xmlns" attribute with explicit inline content <send id="send-123" target="'http://scxml-processors.example.com/session2'" type="'scxml'" xmlns:csta="http://www.ecma.ch/standards/ecma-323/csta"> <csta:MakeCall> <csta:callingDevice>22343</callingDevice> <csta:calledDirectoryNumber>18005551212</csta:calledDirectoryNumber> </csta:MakeCall> </send>
Here is the actual XML message that will be sent:
<scxml:message xmlns:scxml="http://www.w3.org/2005/07/scxml" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2005/07/scxml scxml-message.xsd" source="http://scxml-processors.example.com/session1" target="http://scxml-processors.example.com/session2" sendid="send-123"> <scxml:payload xmlns:csta="http://www.ecma.ch/standards/ecma-323/csta"> <csta:MakeCall> <csta:callingDevice>22343</csta:callingDevice> <csta:calledDirectoryNumber>18005551212</csta:calledDirectoryNumber> </csta:MakeCall> </scxml:payload> </scxml:message>
Here is sample SCXML code to process the resulting event in the receiving SCXML session. It uses the special executable content <csta:makecall> to generate a telephone call:
SESSION2 : RECEIVING SESSION Pattern: "xmlns" attribute with explicit inline content <scxml:transition event="external.event"> <csta:makecall callingDevice="data('_event')/csta:MakeCall/csta:callingDevice" callingDirectoryNumber="data('_event')/csta:MakeCall/csta:callingDirectoryNumber"/> </scxml:transition>
EXAMPLE 3: Finally, here is an example generated by <send> using both 'event' and'namelist' attributes and using JSON content:
SESSION1 : SENDING SESSION Pattern: "event" attribute with an optional "namelist" <datamodel> <data id="email" expr="'mailto:recipient@example.com'"/> <data id="content" expr="'http://www.example.com/mycontent.txt'"/> <data id="jsoncontent" src="http://www.example.com/headers.json"/> </datamodel> ... <send sendid="send-123" target="'http://scxml-processors.example.com/session2'" type="'scxml'" event="'email.send'" namelist="email content jsoncontent" hints="'Email headers'"/>
Here is the actual XML message that will be sent over platform-specific transport and converted into an event in the target SCXML session:
<scxml:message xmlns:scxml="http://www.w3.org/2005/07/scxml" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2005/07/scxml scxml-message.xsd" source="http://scxml-processors.example.com/session1" target="http://scxml-processors.example.com/session2" sendid="send-123" name="email.send" language="json"> <scxml:payload> <scxml:property name="email">mailto:recipient@example.com</scxml:property> <scxml:property name="content">http://www.example.com/mycontent.txt</scxml:property> <scxml:property name="jsoncontent"> <scxml:hint>Email headers</scxml:hint> <![CDATA[ headers : { cc : "audit@example.com" , subject : "Example email" } ]]> </scxml:property> </scxml:payload> </scxml:message>
Here is sample SCXML code to process the resulting event in the receiving SCXML session. In this example, <my:email> is special executable content as in the first example.
SESSION2 : RECEIVING SESSION Pattern: "event" attribute with an optional "namelist" <scxml:transition event="email.send"> <my:email to="_event.email" cc="_event.jsoncontent.headers.cc" subject="_event.jsoncontent.headers.subject" content="_event.content"/> </scxml:transition>
In some cases it may be convenient to included multiple <message> structures in a single payload. The following schema defines a <messages> element which contains multiple <message> elements. Support for this schema is optional.
scxml-messages.xsd
<?xml version="1.0" encoding="UTF-8"?> <!-- XML Schema for sending messages to SCXML processors. --> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:scxml="http://www.w3.org/2005/07/scxml" targetNamespace="http://www.w3.org/2005/07/scxml" elementFormDefault="qualified"> <xsd:include schemalocation="scxml-message.xsd"/> <xsd:annotation> <xsd:documentation xml:lang="en"> XML Schema for sending messages to SCXML processors. Version 1.0 </xsd:documentation> <xsd:documentation source="scxml-copyright.xsd" /> </xsd:annotation> <xsd:attributeGroup name="scxmlmessages.extra.attribs"> <xsd:annotation> <xsd:documentation> Group allowing attributes from other namespaces </xsd:documentation> </xsd:annotation> <xsd:anyAttribute namespace="##other" processContents="lax" /> </xsd:attributeGroup> <xsd:attributeGroup name="scxmlmessages.messages.attlist"> <xsd:attribute name="version" type="xsd:string" fixed="1.0" use="required" /> <xsd:attributeGroup ref="scxml:scxmlmessages.extra.attribs" /> </xsd:attributeGroup> <xsd:group name="scxmlmessages.messages.content"> <xsd:sequence> <xsd:element ref="scxml:message" minOccurs="1" maxOccurs="unbounded" /> </xsd:sequence> </xsd:group> <xsd:complexType name="scxmlmessages.messages.type"> <xsd:group ref="scxml:scxmlmessages.messages.content" /> <xsd:attributeGroup ref="scxml:scxmlmessages.messages.attlist" /> </xsd:complexType> <xsd:element name="messages" type="scxml:scxmlmessages.messages.type" /> </xsd:schema>
The Basic HTTP Event I/O Processor is intended as a minimal interoperable mechanism for sending and receiving events between external components and SCXML 1.0 implementations. Support for the Basic HTTP Event I/O Processor is optional, but implementations that implement this processor MUST support sending and receiving messages in the SCXML message format using it( D.10 SCXML Message Schema ).
The access URI for the Basic HTTP Event I/O Processor is the URI to which an external component can send an event for injection into an active session.
In profiles supporting both the Data Module and the External Module, the access URI is available via the system variable _ioprocessors using the key "basichttp". For example, in 9.2 The ECMAScript Profile ,_ioprocessors["basichttp"] returns the access URI (e.g. http://www.example.com/scxml/basichttp) for the basichttp processor.
The access URI for the Basic HTTP Event I/O Processor may be sent to external components by, for example, its inclusion in the namelist attribute of the <send> element.
The access URI may also be specified in an implementation-specific manner (for example, product documentation).
Input from external components can be received by the SCXML implementation at the basichttp access URI as HTTP POST requests (see [HTTP] ). If the HTTP parameter '_content' is present, its value will be interpreted as a message in the SCXML message format ( D.10 SCXML Message Schema ). Such messages are mapped to SCXML events as described in G SCXML Event I/O Processor .Implementations MAY accept other parameters as well. In such cases, the mapping of their values to SCXML events is implementation-specific.
The Basic HTTP Event I/O Processor validates the message it has received, builds the appropriate SCXML event and adds it to the appropriate event queue. It then indicates the result to the external component via a success response code 2XX. Note that this response is sent before the event is removed from the queue and processed.
In the cases where the message cannot be formed into an SCXML event, the processor MUST return an HTTP error code as defined in [HTTP] .The following codes are assigned a more specific meaning in the SCXML context:
Events can be sent from the SCXML implementation to an external component with the Basic HTTP Event I/O Processor using the <send> element (see 4.1 <send> ) with the type attribute set to "basichttp". The target attribute is set to the access URI of the external component.
The HTTP method is "POST" and parameter values are encoded by default in an application/x-www-form-urlencoded body (POST method). This default encoding MAY be overriden in a platform-specific way, e.g. by using the 'hints' attribute.
If the namelist attribute is defined, its variable names and values are mapped to HTTP parameters. If one or more <param> children are present, their names (i.e. name attributes) and values are mapped to HTTP parameters. If a <content> child is present, its value is mapped to the distinguished HTTP parameter '_content'.
If the external component returns any HTTP response code other than 2XX, the implementation will raise the error error.send.failed.http. error_code in the session that attempted to send the event, where error_code is the HTTP error code that was received.