// Clone root datamodel
if (stateMachine == null) {
log.error(ERR_NO_STATE_MACHINE);
throw new ModelException(ERR_NO_STATE_MACHINE);
} else {
Datamodel rootdm = stateMachine.getDatamodel();
SCXMLHelper.cloneDatamodel(rootdm, rootCtx,
scInstance.getEvaluator(), log);
}
// all states and parallels, only states have variable contexts
for (Iterator i = stateMachine.getTargets().values().iterator();
i.hasNext();) {
TransitionTarget tt = (TransitionTarget) i.next();
if (tt instanceof State) {
Context context = scInstance.lookupContext(tt);
if (context != null) {
context.reset();
Datamodel dm = tt.getDatamodel();
if (dm != null) {
SCXMLHelper.cloneDatamodel(dm, context,
scInstance.getEvaluator(), log);
}
}