`

State Chart XML (SCXML): State Machine Notation for Control

阅读更多

W3C

State Chart XML (SCXML): State Machine Notation for Control Abstraction 1.0

W3C Working Draft 5 July 2005

This version:
http://www.w3.org/TR/2005/WD-scxml-20050705/
Latest version:
http://www.w3.org/TR/scxml/
Previous version:
This is the first version.
Editors:
RJ Auburn, Voxeo
Jim Barnett, Aspect Communications
Michael Bodell, Tellme Networks
T.V. Raman, IBM

Status of this Document

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 first Public Working Draft of SCXML for review by W3C Members and other interested parties, and has been developed by the Voice Browser Working Group (W3C Members only) as part of the W3C Voice Browser Activity.

SCXML is a candidate for the control language within VoiceXML 3.0 (currently under development by the Voice Browser working group), CCXML 2.0 (anticipated development in 2006 by the Voice Browser working group), and the multimodal authoring language (under development by the Multimodal Interaction working group).

Comments for this specification are welcomed to www-voice@w3.org (archives).

This document was produced under the 5 February 2004 W3C Patent Policy. The Working Group maintains a public list of patent disclosures relevant to this document; that page also includes instructions for disclosing [and excluding] a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) with respect to this specification should disclose the information in accordance with section 6 of the W3C Patent Policy.

Per section 4 of the W3C Patent Policy, Working Group participants have 150 days from the title page date of this document to exclude essential claims from the W3C RF licensing requirements with respect to this document series. Exclusions are with respect to the exclusion reference document, defined by the W3C Patent Policy to be the latest version of a document in this series that is published no later than 90 days after the title page date of this document.

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.

Table of Contents

1 Terminology
2 Overview
3 Basic State Notation
    3.1 SCXML
        3.1.1 Properties
    3.2 STATE
        3.2.1 Properties
    3.3 TRANSITION
        3.3.1 Properties
    3.4 PARALLEL
        3.4.1 Properties
4 Pseudo-States
    4.1 INITIAL
        4.1.1 Properties
    4.2 HISTORY
        4.2.1 Properties
    4.3 JOIN
        4.3.1 Properties
    4.4 SYNCH
        4.4.1 Properties
5 Executable Content
    5.1 Variables and Expressions
        5.1.1 <assign></assign>and
            5.1.1.1 Overview
            5.1.1.2 Attribute Details
            5.1.1.3 <assign></assign>Attribute Details
    5.2 Event Control
        5.2.1 <send></send>
            5.2.1.1 Overview
            5.2.1.2 Attribute Details
        5.2.2 <cancel></cancel>
            5.2.2.1 Overview
            5.2.2.2 Attribute Details
    5.3 Flow Control Elements
        5.3.1 <if></if>
            5.3.1.1 Overview
            5.3.1.2 Attribute Details
        5.3.2 <elseif></elseif>
            5.3.2.1 Overview
            5.3.2.2 Attribute Details
        5.3.3 <else></else>
            5.3.3.1 Overview
            5.3.3.2 Attribute Details
    5.4 Debugging Elements
        5.4.1 <log></log>
            5.4.1.1 Overview
            5.4.1.2 Attribute Details
6 Conditional Expressions
    6.1 Special Predicates
        6.1.1 In
            6.1.1.1 Overview
            6.1.1.2 Attribute Details
7 Related Work

Appendices

A Open Issues
    A.1 Empty Event Property of Transition
    A.2 Scoping Rules for ID
    A.3 State Templates
    A.4 XML Content in Send
    A.5 junction, choice, fork, and join
    A.6 Automatic Logging
B Schema
C CCXML to SCXML Conversion
D Examples
    D.1 Language Overview
E An Overview of Harel State Table Notation and Semantics
    E.1 A Simple State Machine
    E.2 Executing Actions On Entering And Exiting
    E.3 Complex States
    E.4 Parallel States
    E.5 Concurrency And Event Queues
    E.6 Synchronizing And Concurrency
    E.7 Sync Explained
    E.8 Microwave Oven
F References


1 Terminology

[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].

2 Overview

This document outlines a state machine notation that combines concepts from CCXML and Harel State Tables. It is intended to be a general-purpose state machine language that can be used in multiple contexts, including VoiceXML 3.0, CCXML 2.0, and the MultiModal Interaction framework. 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 are part of UML [UML 1.5]. 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. For an overview of the UML notation and a brief outline of its semantics, see E An Overview of Harel State Table Notation and Semantics, below.

For simplicity's sake, the language definitions below refer to the 'properties' of elements, without specifying whether said properties are attributes or children. The markup samples at the end of the document make specific decisions about what is an attribute and what is a child element, but we may revise these decisions as refine the definitions.

For concreteness sake, we use ECMAScript as the language for data elements, but the complete language definition will permit other languages such as XPath to be used as well.

3 Basic State Notation

3.2 STATE

Holds the representation of a state machine.

3.3 TRANSITION

Transition rules are triggered by events and conditionalized via guard-conditions. The optional property target specifies the destination of the transition, which may be a state or a parallel region. If the target property 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 supplied via the actions property. Such a transition is equivalent to an 'event' handler in HST 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.

The target property may specify the destination by id or in-line. In the latter case, the in-lined state is private to the transition in the sense that no other transition may take it as a target. This convention allows an in-lined state to be used as a form of scratch state which is visible only locally.

3.4 PARALLEL

Wrapper element to encapsulate parallel state machines. The parallel element has onenter and onexit properties analogous state. In addition, the parallel element holds a set of state elements that execute in parallel and join at the onexit handler of element parallel. In particular, when all of the parallel substates reach a final state, a completion event "ID.done" is generated, where "ID" is the 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.

For the parallel element to be useful, each of its state substates must itself be a complex state, i.e., one with either state or parallel children. When the state machine enters the parent parallel element, it simultaneously enters each child state. Transitions wihthin the individual child elements operate normally, but there may not be transitions between the child elements since that would violate the semantics of parallelism. 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 no determinate order, followed by that for the parent parallel element, followed by an action expression in the transition element, and then the onentry handlers in the target state.

4 Pseudo-States

The following elements are called 'pseudo-states' because they do not have the full properties of states (for example they lack onentry and onexit handlers) and do not map to states in the underlying semantics of the language. However, they can be used like states in many places. In particular, they can often be the target of transition. They are a notational shorthand allowing the simple statement of some sophisticated control constructs.

4.2 HISTORY

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.

5 Executable Content

Executable Content consists of actions that are performed when the selected handler is executed. In general, such content must be able to set variables, raise events, and invoke functionality in the underlying platform. On the other hand, Executable Content may not cause transitions or any form of change of state, except indirectly, by raising events that are then caught by transitions. There are a variety of possible forms for Executable Content, particularly since the capabilities of the underlying platform vary across implementations. The content presented here is closely based on that in CCXML. This is partly for reasons of backward compatibility, but also because CCXML's executable content is quite flexible, consisting of Flow Control Elements, Event Control Elements or Custom Action Elements.

Flow Control Elements are used to control the flow of execution within Executable Content.

Event Control Elements are used to control how and when events are sent from SCXML.

Custom Acton Elements can be defined in other specifications/namespaces and are responsible for performing actions on behalf of custom components. Logically Custom Acton Elements can be thoughts of a collection of actions and handlers to perform specific tasks. An example of this is a CCXML <accept></accept>element that is a Custom Acton Element:

<transition event="ccxml:connection.alerting" name="evt"></transition>
  <ccxml:accept connectionid="evt.connectionid"></ccxml:accept>

This could be written using a <send></send>element using the following syntax:

<transition event="ccxml:connection.alerting" name="evt"></transition>
  
  <send event="ccxml:accept" namelist="connectionid" targettype="ccxml"></send>

A more complicated example might be a CCXML <createcall></createcall>where you are both providing variables and getting values back that using only the <send></send>syntax would be more complex as it would need to be broken over several steps. For example:

<onentry></onentry>
  <ccxml:createcall connectionid="myConnectionID" dest="'tel:+18315552020'"></ccxml:createcall> 

Would need to be modeled in two steps using <send></send>as you would need to do something like the following:

<onentry></onentry>
  
  <send event="ccxml:createcall" namelist="dest" targettype="ccxml"></send>

<transition event="ccxml:createcall.success" name="evt"></transition>
  

The exact mappings between Custom Action Elements and <send></send>actions are to be defined in the individual Custom Action Element specifications.

5.2 Event Control

5.2.1 <send></send>

5.2.1.1 Overview

<send></send>is used to send messages containing events or other information directly to another SCXML Interpreter, other external systems using an Event I/O Processor or to raise events in the current SCXML session.

The event target of <send></send>is specified using the target and targettype 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 Event I/O Processor should send the event to. This can be the value of a SCXML Session ID to another SCXML session. In the case where you are using some other Event I/O Processor this attribute should be able to describe how to connect to the event destination (For example a SIP URL for SIP-INFO messages or a HTTP URL for Web Services). If no target attribute is specified the default target is the current SCXML session. If the value of the target attribute is not supported, invalid or unreachable by the Event I/O Processor the Platform MUST throw a error.send.targetunavailable event.

The targettype attribute controls what Event I/O Processor the event should be sent to. The default value of this attribute is 'ssxml'. If the event targettype specified is not supported the platform MUST throw a error.send.targettypeinvalid event.

A platform must support the following values for the targettype attribute:

Value Details
scxml SCXML Session Event 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 Event I/O Processor beginning with "x-" to signify that they are platform dependent.

<send></send>also specifies the content of the message to be sent. <send></send>may specify message content in one of two ways (the following mechanisms are mutually exclusive):

  • event attribute with an OPTIONAL namelist

    • The event attribute specifies an expression that returns the name of the event.

    • The namelist attribute specifies a space separated list of variables to be included with the message.

    
    
    <send event="'fax.SEND'" namelist="content" targettype="'x-messaging'" target="target"></send>
    


  • xmlns attribute with explicit content inline XML content specifying the message to sent the xmlns:<namespace></namespace> defines a namespace for the inline content

    <send targettype="'x-csta'" target="'csta://csta-server.example.com/'" xmlns:csta="http://www.ecma.ch/standards/ecma-323/csta"></send>
          <csta:makecall>
            <csta:callingdevice>22343
            <csta:calleddirectorynumber>18005551212</csta:calleddirectorynumber>
          </csta:callingdevice></csta:makecall>
    
    


If an explicit namespace is provided as in the xmlns attribute of the <send></send>, this namespace can be used to validate the content of the <send></send>. A namespace specified on a <send></send>applies only to the attributes and content of the <send></send>. Multiple namespaces MAY be included in the <send></send>to associate message content with more than one namespace.

When an explicit namespace is specified for the <send></send>, the content of the <send></send>is parsed but can be ignored by the sending SCXML Interpreter until the <send></send>is executed. XML namespace identifiers contained in the <send></send>MUST be preserved and it is the responsibility of the Event I/O Processor responsible for forwarding events to the <send></send>target to parse the incoming message and remove the namespace prefix, if required by the <send></send>target.

The sending SCXML Interpreter MUST NOT alter the content of the <send></send>. The data contained within a <send></send>MUST be sent to the destination specified in the target attribute of <send></send>using the Event I/O Processor specified by the targettype attribute. When <send></send>is used with inline XML content, and the target is a SCXML session, the mapping of that XML content to event object properties is implementation-specific, and outside the scope of this specification. Although the full set of requirements for the Event I/O Processor is not within the scope of this specification, an event processor sending an event to a SCXML Interpreter is required to generate an event which can be processed in a SCXML Session. See Section 9.1 for details regarding the processing of incoming events by an SCXML Interpreter.

When a message is successfully sent to the target, a send.successful event will be thrown. Note that this does not mean that the target processed the message successfully. It is up to the target to generate events specific to the message. These events are application specific.

If the send request fails, an event signifying the error will be returned to the SCXML Session. The failure events are documented at the end of this section.

5.2.1.2 Attribute Details
Name Required Attribute Constraints Type Default Value Valid Values Description
event false This attribute may not be specified in conjunction with inline content Expression none   An expression which returns a character string that indicates the type of event being generated. The event type may include alphanumeric characters and the "." (dot) character. The first character may not be a dot or a digit. Event type names are case-insensitive. If neither the data attribute or inline content is specified, an error.fetch event will be thrown. If used in conjunction with the inline content, an error.fetch will be thrown.
target false   Expression none A valid target URL An expression returning the target location of the event. The target attribute specifies the unique identifier of the event target that the Event I/O Processor should send the event to.
targettype false   Expression scxml scxml An expression which returns a character string that specifies the type of the Event I/O Processor that the event should be dispatched to. Values defined by the specification are:
  • scxml - This species that the event will be dispatched to the SCXML Session Event Processor.

sendid false   Left Hand Side Expression none Variable An left hand side expression evaluating to a previously defined variable. The value of the attribute will receive an internally generated unique string identifier to be associated with the event being sent. If this attribute is not specified, the event identifier is dropped.
delay false   Expression '0s' An expression which returns a character string in CSS2 [CSS2] format The character string returned is interpreted as a time interval. The send tag will return immediately, but the event is not dispatched until the delay interval elapses. Timers are useful for a wide variety of programming tasks, and can be implemented using this attribute. Note: The queue for sending events is maintained locally. Any events waiting to be sent will be purged when the session that issued this request terminates.
xmlns:[YourNameSpacePrefix] false   string none   This returns a namespace identifying the contained message format. More than one xmlns attribute may be included.
namelist false This attribute may not be specified in conjunction with inline content Var List none List of Variable names A list of zero or more whitespace separated CCXML variable names to be included with the event. When an variable is included with the event, its value is first converted into a string. If the variable is an Object, the mechanism by which it is included is not currently defined. Instead of including Objects directly, the application developer may explicitly include the properties of an Object. e.g. "date.month date.year". If used in conjunction with the inline content, an error.fetch will be thrown.
hints false   Expression none An expression. The data returned contains information which may be used by the implementing platform to configure the event processor. The meaning of these hints is specific to the implementing platform and the event processor.

5.3 Flow Control Elements

5.3.1 <if></if>

5.3.1.1 Overview

<if></if>is a container for conditionally executed elements. <else></else>and <elseif></elseif>can optionally appear within an <if></if>as immediate children, and serve to partition the elements within an <if></if>. <else></else>and <elseif></elseif>have no content. <else></else>is a synonym for <elseif cond="true"></elseif>.

Each partition within an <if></if>is preceded by an element having a cond attribute. The initial partition is preceded by the <if></if>and subsequent partitions by <elseif></elseif>s (or <else></else>s). The first partition in document order with a cond that evaluates to true is selected. <else></else>always evaluate to true. A partition may be empty.

If an <if></if>has no immediate <elseif></elseif>or <else></else>children, the full contents of the <if></if>will be selected when the cond attribute is true.

<else></else>was chosen to match similar concepts in other languages, and supports examples such as

<if cond="..."></if>
  <!----> is true ->
  <else></else>
  <!----> is false ->

           

However, <else></else>is a synonym for <elseif cond="true"></elseif>, so an example such as:

<if cond="..."></if>
  <!----> is true ->
  <else></else>
  <!----> is false ->
  <else></else>
  <!---->

 

is also possible and must be interpreted as:

<if cond="..."></if>
  <!----> is true ->
  <elseif cond="true"></elseif>
  <!----> is false ->
  <elseif cond="true"></elseif>
  <!---->

With this definition for <else></else>, a valid XML [XML] document is also a valid SCXML document.

7 Related Work

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.

评论

相关推荐

    Scxml.zip_java项目_scxml

    SCXML(State Chart eXtensible Markup Language)是一种标准的、通用的状态机表示语言,它由W3C制定,主要用于定义复杂的状态行为模型。在Java项目中,SCXML被广泛用于构建状态驱动的应用程序,例如GUI系统、智能...

    scxml-tutorials:SCXML系列教程

    SCXML(State Chart eXtensible Markup Language)是一种标准的、通用的状态机表示语言,它由W3C制定,主要用于描述复杂的状态行为逻辑。SCXML的设计目标是为各种不同的环境提供一个统一的、可扩展的方式来定义和...

    SCXML2VoiceXMLJ:项目 PB138

    SCXML2VoiceXMLJ 是一个基于Java的项目,主要用于转换SCXML(State Chart XML)文档为VoiceXML(Voice Extensible Markup Language)文档。这个项目,PB138,旨在实现一种工具,它能够将SCXML定义的状态机逻辑转化为...

    将EXCEL文件全方位解析成生成XML数据

    至于"SCXML",它可能是“State Chart XML”的缩写,这是一种定义状态机行为的XML规范,常用于复杂交互系统的建模。虽然标题和描述没有直接提及SCXML,但它是XML家族的一员,表明XML在不同领域的广泛应用。 综上所述...

    scxml-viz:一个基于 d3 的库,用于使用 SVG 可视化 SCXML

    注意:我们开发了一个新的 SCXML 可视化库: 一个基于 d3 的库,用于使用 SVG 可视化 SCXML。 有关如何使用 scxml-viz 的示例,请参见 viz。 命令行使用 可以使用 PhantomJS 从命令行生成图形。 ./render.sh in....

    state-machine-cat:写出漂亮的状态图

    状态机猫写出漂亮的状态图什么? 使这个 由此initial,doing: entry/ write unit test do/ write code exit/ ...,# smcat recognizes initial# and final states by name# and renders them appropriatelyfinal;...

    Control Isolator:基于 Apache Commons SCXML 状态机的控制流 Java 库-开源

    状态机在 WYSIWYG 设计器的帮助下可视化定义并以通用 xml 格式存储:在执行期间,可以通过连接到套接字来可视化跟踪应用程序的状态。 在库的幕后,SCXML - Apache Commons 库被用来运行状态机。 ...

    scxml-android:适用于 Android 的 Scxml 库

    Scxml-android 是一个专门为 Android 平台设计的 SCXML(状态机配置语言)库。SCXML 是一种标准的、开放的、平台无关的语言,用于描述复杂的、基于事件的状态机行为。这种语言由 W3C(万维网联盟)制定,主要用于...

    rodin_scxml_plugin:该存储库用于保存开发scxml rodin插件的材料。 这包括scxml模型示例以及该工作产生的任何手稿

    rodin_scxml_plugin是一个专门为开发SCXML(State Chart eXtensible Markup Language)与Rodin平台集成的插件而创建的存储库。这个项目的主要目标是提供一个工具集,使得用户能够利用Rodin平台来编辑、模拟和验证...

    apache commons scxml2.0

    apache commons scxml 2.0 只有这里才有哦,官网上面只有0.9版本,需要自己下载源码编译,这里我已经编译好了,连同依赖的jar包都在这里了。想知道怎么使用SCXML,可以参考我的博客:...

    scxml.js:面向SCION Statecharts引擎的轻量级SCXML到JavaScript编译器

    scxml.js是面向下一代 Statecharts解释器的轻量级SCXML到JavaScript编译器。 它目前支持node.js和浏览器,以后将支持Rhino和其他JavaScript环境。 请注意,scxml.js仍然是新的,应被视为具有Beta质量的软件。 有关更...

    atom-state-machine-cat-preview:用于编写(和预览)精美状态机图表的Atom程序包

    按下ctrl-shift-G时,在当前编辑器窗口中显示smcat或scxml的已渲染有限状态机图。 为.smcat和.scxml文件启用产品特点语法高亮实时渲染状态机图SVG导出-到文件或剪贴板PNG导出-到文件使用纯javascript 包进行解析和...

    commons-scxml2-2.0-SNAPSHOT.jar

    commons-scxml2-2.0-SNAPSHOT.jarcommons-scxml2-2.0-SNAPSHOT.jar

    atphu:类似于SCXML的状态机

    SCXML(State Chart XML)是W3C标准,它提供了一种通用的、可扩展的机制来表示复杂的、基于事件的状态机。而"atphu"则是一个非官方的实现,类似于SCXML,但可能更加轻量级且适应TypeScript编程语言。 SCXML的核心...

    scxml-hdl:探索scxml如何应用于诸如VHDL或Verilog的数字逻辑语言

    scxml-hdl 探索SCXML如何应用于诸如VHDL或Verilog的数字逻辑语言。 高密度脂蛋白 通常由一组状态定义,即IFL(输入形成逻辑或下一状态逻辑)和OFL(输出形成逻辑,通常是组合输出逻辑)。 IFL定义了在什么条件下...

    scxml2-android:适用于Android的Apache Commons SCXML2

    scxml2-android在Android上运行的实现的版本。 最少的更改集,主要是围绕日志记录的更改,以启用在Android平台上编译和运行SCXML2的功能。 这些更改尽可能地是非侵入性的,尽管它们不会更改状态机代码的功能,但它们...

    stateful:RESTful状态机

    curl -i -H"Content-type: application/xml" -XPUT --data-binary @"src/test/resources/state.xml" http://localhost:8080/statefulapp/resources/machines/duke 样本文件: &lt; scxml xmlns = " ...

    statechart-jsx:用于xstate的受SCXML启发的JSX编译指示

    这是一种实验性的JSX编译指示,允许人们在尽可能严格地遵循SCXML习惯用法的同时使用xstate。 Xstate是一个了不起的库,但是语法可能具有挑战性,因为JavaScript的数据结构并不特别适合于表达状态机。 对于那些发现...

    qxmledit:QXmlEdit XML编辑器。 下载:https:sourceforge.netprojectsqxmleditfiles

    它支持XML Schema(XSD)验证,允许用户以结构化的方式查看和编辑XML文档,并且具备了文件拆分、SCXML(状态机配置语言)处理以及XML比较等多种功能。 XML(eXtensible Markup Language)是一种标记语言,用于存储...

    uscxml:以CC ++编写的SCXML解释器和Transformercompiler,具有对Java,C#,Python和Lua的绑定

    uscxml-browser :SCXML文档的符合标准的。 uscxml-transform :实现的集合,可SCXML为例如ANSI-C和VHDL。 可以在检查有关的各种数据模型,绑定和生成器的状态。 安装 尚无安装程序,并且我们不提供任何版本。 只...

Global site tag (gtag.js) - Google Analytics