SCXML-tutorial

Contents Overview Examples Editor Forum

<onentry>

Video version

A wrapper element containing executable content to be executed when the state is entered.

The SCXML processor must execute the <onentry> handlers of a state in document order when the state is entered. In doing so, it must treat each handler as a separate block of executable content.

onentry-onexit - onentry

<scxml initial="State1" name="Scxml" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
	<state id="State1">
		<onentry>
			<log expr="Hello from 'State1'!"/>
		</onentry>
		<transition target="Container"/>
	</state>
	<final id="End">
		<onentry>
			<log expr="Hello from 'End'!"/>
		</onentry>
	</final>
	<state id="Container" initial="State2">
		<onentry>
			<log expr="Hello from 'Container'!"/>
		</onentry>
		<transition target="End"/>
		<state id="State3">
			<onentry>
				<log expr="Hello from 'State3'!"/>
			</onentry>
		</state>
		<state id="State2">
			<onentry>
				<log expr="Hello from 'State2'!"/>
			</onentry>
			<transition target="State3"/>
		</state>
	</state>
</scxml>

Output:

[Log] "Hello from 'State1'!"
[Log] "Hello from 'Container'!"
[Log] "Hello from 'State2'!"
[Log] "Hello from 'State3'!"
[Log] "Hello from 'End'!"

W3C IRP tests

1. Test 375

The SCXML processor MUST execute the onentry handlers of a state in document order when the state is entered.

test375

2. Test 376

The SCXML processor MUST treat each <onentry> handler as a separate block of executable content.

test376

TOP Contents Overview Examples Editor Forum