Skip to content

Element <transition>

Purpose: Connect one state to another with an optional positive selection weight.

Why: Use it inside a state machine to define one allowed next-state edge and its weight.

Example

1
<transition from="open" to="paid"/>

Decision guide

Business value: Makes one allowed lifecycle edge and its relative likelihood reviewable.

  • Use when

    • A state-machine permits a transition from one named state to another.
  • Choose another approach when

    • Defining an independent value or using it outside a state-machine.
  • Prerequisites

    • Place it inside state-machine and reference valid state names.

Complete examples

Generate a deterministic order lifecycle from a transition graph

Use a state machine when values must follow allowed business transitions instead of independent random selection.

order-lifecycle/datamimic.xml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<setup rngSeed="42">
    <state-machine id="order_lifecycle" start="open">
        <transition from="open" to="paid"/>
        <transition from="paid" to="shipped" weight="0.9"/>
        <transition from="paid" to="cancelled" weight="0.1"/>
        <transition from="shipped" to="delivered"/>
    </state-machine>
    <generate name="orders" count="20" target="LogExporter">
        <key name="status" generator="order_lifecycle"/>
    </generate>
</setup>

Rules and invalid combinations

I919 โ€” State Machine Transition Unknown Attribute

has unknown attribute(s) {attrs}, expected only 'from', 'to', 'weight'

Why: A child of declared an attribute outside 'from'/'to'/'weight'.

Resolution: Remove the unexpected attribute(s) or correct the spelling.

Full rule

I920 โ€” State Machine Transition Missing From/To

requires non-empty 'from' and 'to' attributes

Why: A child of is missing 'from' and/or 'to'.

Resolution: Provide both 'from' and 'to' on every .

Full rule

I921 โ€” State Machine Transition Weight Not Numeric

weight must be numeric, got '{weight}'

Why: A value could not be parsed as a float.

Resolution: Use a numeric weight, e.g. weight="0.9".

Full rule

I922 โ€” State Machine Transition Weight Not Positive

weight must be > 0, got {weight}

Why: A value is zero or negative.

Resolution: Use a strictly positive weight (or omit weight= for the default of 1.0).

Full rule

Allowed parents / Allowed children

Allowed parents: else, else-if, if, state-machine, while

Allowed children:

None

Attributes

Show all 3 attributes

from

State from which this directed transition starts.

required; string.

to

State reached when this transition is selected.

required; string.

weight

Positive relative probability among transitions with the same from state.

optional; number; Default: 1.0.