Also, when using the src attribute, here is a general pattern that
supports good encapsulation practices:
<state id="foo" src="foo.xml">
<transition event="foo.done" target="bar"/>
</state>
<state id="bar">
...
</state>
On Mon, Jul 21, 2008 at 11:28 AM, Rahul Akolkar <[EMAIL PROTECTED]> wrote:
> On Mon, Jul 21, 2008 at 9:59 AM, Berg, T.W. (Tom) van den
> <[EMAIL PROTECTED]> wrote:
>> I would like to reuse a statediagram in an overall state diagram. The
>> src attribute in the state tag seems to suggest this is possible.
>> For example the main state.xml file would contain:
>>
>> ----
>>
>> <state id="Composite1" src="include.xml">
>> <state id="finalState">
>> <transition target="Composite2"/>
>> </state>
>> </state>
>>
>> <state id="Composite2" src="include.xml">
>> <state id="finalState">
>> <transition target="Composite3"/>
>> </state>
>> </state>
>>
>> <state id="Composite3" src="include.xml">
>> <state id="finalState">
>> </state>
>> </state>
>>
>> ----
>>
>> And the (simplified) include.xml looks like:
>>
>> <scxml xmlns="http://www.w3.org/2005/07/scxml
>> <http://www.w3.org/2005/07/scxml> "
>> xmlns:rti="http://rti.actions/CUSTOM <http://rti.actions/CUSTOM>
>> "
>> version="1.0"
>> initialstate="sp">
>>
>> <state id="sp">
>> <transition target="finalState"/>
>> </state>
>> </scxml>
>>
>>
>> ----
>>
>> However, this example does not work.
>>
>> I get the following error:
>> 21-jul-2008 15:50:24 org.apache.commons.scxml.io.ModelUpdater
>> logAndThrowModelError
>> SEVERE: Initial state null or not a descendant of state with ID
>> "Composite1"
>>
> <snip/>
>
> There are (atleast) three states in the above document with the same
> ID ("finalState"), which violates the uniqueness constraint.
>
>
>> Does nesting and state reuse work this way?
> <snap/>
>
> Yes, when done right. Some notes contributed by users to the wiki on
> this topic may also be helpful:
>
> http://wiki.apache.org/commons/SCXML/Tutorials/Templating
>
>
>> What are alternate ways to reuse state diagrams?
>>
> <snip/>
>
> I know folks have suggested using XML entities, but that doesn't
> necessarily address "importing" such fragments multiple times into the
> same SCXML state machine definition.
>
> -Rahul
>
>
>>
>> -- Tom
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]