scjson

scjson logo

SCXML to SCJSON Inference Guide

This document describes how the JavaScript converter transforms SCXML into the scjson format. It captures the inference logic encoded in js/src/converters.js so that other language implementations can reproduce identical behaviour.

1. Overview

2. Conversion Entry Point

3. Structural Field Extraction

The converter lifts specific child elements out of content[] so that they live directly on the parent object. Each of the following tags becomes an array property on its parent:

When any of these elements are present:

  1. Initialise an array for the matching property (e.g. state: []).
  2. Place converted child objects in this array.
  3. Do not leave the raw element in content[] unless its tag is unknown.

4. Content Array Handling

5. Other Attributes and Fallbacks

6. Examples

SCXML Input

<state id="parent">
  <transition event="go" target="child"/>
  <state id="child"/>
  <onentry>
    <log label="start" expr="enter"/>
    <foo/>
  </onentry>
</state>

Converted SCJSON

{
  "tag": "state",
  "id": "parent",
  "transition": [{
    "tag": "transition",
    "event": "go",
    "target": ["child"]
  }],
  "state": [{ "tag": "state", "id": "child" }],
  "onentry": [{
    "tag": "onentry",
    "log": [{ "tag": "log", "label": "start", "expr": "enter" }],
    "content": [{ "tag": "foo" }]
  }]
}

The unknown <foo/> element remains inside content[] of the onentry block.

7. Notes on Determinism

8. Implementation Hints