Re: Unique ids for transitions

Le 1 feb 2013 à 00:40, Gavin Kistner a écrit :

> Transitions currently do not specify the presence of an id="..." attribute. As any pair of states can have n transitions anchored at both ends, even with the same event(s), the only way to uniquely talk about a particular transition (to any sort of an external system) is to fully describe it. Contrast this with a state, which can be uniquely identified with a short id string.
> 
> This causes no problem for the runtime itself. However, for external tools working with an SCXML document this can be annoying. I'm thinking specifically of a visual runtime debugger for a state machine. For example, consider the scxmlgui tool[1]. It has a simple network protocol for highlighting/unhighlighting either states or transitions. The states are referred to by id. The transitions are referred to by source/target state ids, which clearly does not uniquely reference a specific transition in all cases.
> 
> It will be trivial to add a namespaced attribute to transitions to track this, but I would feel cleaner if this were in the spec itself. Any chance of having an a non-required id (ID) attribute spec'd on <transition> elements?

There are two ways to reliably reference a transition without an identifier:
- by state id and event+cond, which should be unique within a state
- by using the document structure (basically, using an XPath, CSS selector, or wrapping one of those for convenience)
Using the target of a transition to identify it is insufficient without the above and unnecessary with them, as only the first transition with the same event+cond can ever be enabled.

However, it is true that these methods of reference are not identifiers and I understand that you may wish for one, especially in an editor.

I am opposed to adding the "id" attribute to anything that is not a state. In fact, it is annoying enough that <send> and <data> elements have it. A namespaced attribute (with the right namespace) is actually the clean way to do it, since it is clearly meta-data and, as you said, irrelevant to core SCXML. Besides, making that attribute part of SCXML would mean that authors of SCXML documents would feel compelled to waste time thinking of a name for all their transitions no matter the tools they use to create it. It is better that an IDE add automatically-generated, namespaced identifiers for its internal use if it does need them.

			David

Received on Friday, 1 February 2013 09:02:57 UTC