You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Fabrizio Morbini <fm...@gmail.com> on 2010/05/06 17:34:11 UTC

[scxml] templating/src/xinclude and returning a value(through datamodel/donedata)

Hi, i'm experimenting with the src attribute to reuse fsm. I'm having
some trouble with returning a value from an included fsm to the
calling state.

I'm using this description at
http://shale.apache.org/shale-dialog-scxml/index.html, in particular
the section about subdialogs from which it seems possible to return a
value from an included scxml fsm.
However i have been unable to do so. I've tried several variants but
none with the expected outcome. Here is the current variant:

=============file a.scxml=====================================
<?xml version="1.0"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml"
		xmlns:cs="http://commons.apache.org/scxml"
       version="1.0"
       profile="ecmascript"
       initial="s1">

  <!--  trivial 5 second microwave oven example -->
  <!--  see http://commons.apache.org/scxml/guide/datamodel.html for
different way to access the datamodel -->
  <datamodel>
    <data id="cook_time" expr="10"/>
  </datamodel>

  <state id="s1">
    <!-- off state -->
    <transition target="s2"/>
  </state>

  <state id="s2" src="b.scxml#s111">

    <!-- on/pause state -->

    <transition event="s2.done" cond="aaa eq 's3'" target="s3"/>
    <transition event="s2.done" cond="aaa eq 's4'" target="s4"/>
    <transition event="s2.done" target="s5"/>

  </state>

    <final id="s3"/>
    <final id="s4"/>
    <final id="s5"/>
</scxml>
=============end of file a.scxml==============================

=============file b.scxml=====================================
<?xml version="1.0" encoding="us-ascii"?>
<scxml version="1.0" xmlns="http://www.w3.org/2005/07/scxml"
xmlns:cs="http://commons.apache.org/scxml" initial="s111">
	<state id="s111">
	<initial><transition target="s11"/></initial>
  	<datamodel><data id="aaa"/></datamodel>

    <state id="s11">
		<transition target="s12">
				<!--<cs:var name="aaa" expr="'s3'" />-->
				<assign location="aaa" expr="'s3'"/>
		</transition>
    </state>

	<final id="s12">
	</final>
	</state>
</scxml>
=============end of file b.scxml==============================

i tried to use also <var> instead of a previously defined variable in
the datamodel, without success.

the simple way would be to use the donedata in a final state in the
included fsm but it doesn't seem that donedata is supported, is this
correct?

given that src is not going to be supported in the next standard, do
you have some pointer to examples/doc of how to use xinclude to do
what the src is supposed to do?

thanks,
fabrizio.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [scxml] templating/src/xinclude and returning a value(through datamodel/donedata)

Posted by Rahul Akolkar <ra...@gmail.com>.
On Thu, May 6, 2010 at 2:36 PM, Fabrizio Morbini <fm...@gmail.com> wrote:
> Hi Martin, following Rahul advice and explanation the initial problem
> is now solved. However i would like to follow-up on your reply.
> According to the SCXML standard (i.e.
> http://www.w3.org/TR/scxml/#datamodel)
> in particular:
>
> "Logically, there is a single globally visible data model for the
> entire state machine. As an authoring convenience, however, we allow
> <datamodel> as a child of any <state>, thus allowing parts of the data
> model to be distributed throughout the document closer to the
> locations where the data will be accessed. However, all instances of
> the <data> element are created and initialized when the state machine
> is instantiated and may be accessed from any state at any time."
>
> do you mean that the implementation of datamodel in Apache Commons
> SCXML is different from the working draft?
<snip/>

The Commons SCXML implementation is actually more extensible in that
it can support various kinds of datamodel and/or scoping behavior.

The default behavior in v0.9 if you pick up one of the provided
evaluator implementations is different from the single logical
datamodel (it provides a cascading datamodel, much like the block
scopes in procedural languages such as Java). I mentioned in a
previous note how to provide an evaluator that produces a single /
global data model.


> or that the use of src (and
> in the future xinclude?) invalidates the above statement (i.e. one
> single logical datamodel)?.
>
<snap/>

Use of the src attribute of <state> or XInclude is orthogonal to how
datamodel scopes are structured.

-Rahul


> thanks,
> fabrizio.
>
> On Thu, May 6, 2010 at 11:18, Martin Gainty <mg...@hotmail.com> wrote:
>>
>> Fabrizio-
>>
>> from what ive read in the scxml doc you need to configure the datamodel and their respective data node children directly under the scm root node e.g.
>> <scxml xmlns="http://www.w3.org/2005/07/scxml"
>>               version="1.0"
>>               initialstate="init-travel-plan">
>>
>>      <datamodel>
>>        <data name="airlineticket">
>> //you can use the Data macro to reference the current value of the requested parameters e.g.
>> //Commons SCXML defines a Data()
>>   function for use in JEXL or EL expressions, for example:
>>    <var name="arrival" expr="Data(hotelbooking, 'hotel/stay/arrival')" />
>>
>> //   The above expression extracts the arrival date from the hotelbooking
>> //   data in the documents datamodel and stores it in a scratch space variable
>> //   named "arrival". The first argument is value of the name attribute of the
>> //   <data> element and the second is the String value of the XPath
>> //   expression. If more than one matching nodes are found, the first one
>> //   is returned.   //this is different from your current implementation which uses data elements associated with a state e.g.
>>     <scxml xmlns="http://www.w3.org/2005/07/scxml"
>>               version="1.0"
>>               initialstate="airline-ticket">
>>
>>      <state id="airline-ticket">
>>        <datamodel>
>>          <data...>
>> the association of this data would be to airline-ticket and could not be used in hotel or restaurant
>> a complete scxml tutorial is available at
>> http://commons.apache.org/scxml/guide/datamodel.html
>>
>> HTH
>> Martin Gainty
>> ______________________________________________
>> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
>>
>> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
>> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [scxml] templating/src/xinclude and returning a value(through datamodel/donedata)

Posted by Fabrizio Morbini <fm...@gmail.com>.
Hi Martin, following Rahul advice and explanation the initial problem
is now solved. However i would like to follow-up on your reply.
According to the SCXML standard (i.e.
http://www.w3.org/TR/scxml/#datamodel)
in particular:

"Logically, there is a single globally visible data model for the
entire state machine. As an authoring convenience, however, we allow
<datamodel> as a child of any <state>, thus allowing parts of the data
model to be distributed throughout the document closer to the
locations where the data will be accessed. However, all instances of
the <data> element are created and initialized when the state machine
is instantiated and may be accessed from any state at any time."

do you mean that the implementation of datamodel in Apache Commons
SCXML is different from the working draft? or that the use of src (and
in the future xinclude?) invalidates the above statement (i.e. one
single logical datamodel)?.

thanks,
fabrizio.

On Thu, May 6, 2010 at 11:18, Martin Gainty <mg...@hotmail.com> wrote:
>
> Fabrizio-
>
> from what ive read in the scxml doc you need to configure the datamodel and their respective data node children directly under the scm root node e.g.
> <scxml xmlns="http://www.w3.org/2005/07/scxml"
>               version="1.0"
>               initialstate="init-travel-plan">
>
>      <datamodel>
>        <data name="airlineticket">
> //you can use the Data macro to reference the current value of the requested parameters e.g.
> //Commons SCXML defines a Data()
>   function for use in JEXL or EL expressions, for example:
>    <var name="arrival" expr="Data(hotelbooking, 'hotel/stay/arrival')" />
>
> //   The above expression extracts the arrival date from the hotelbooking
> //   data in the documents datamodel and stores it in a scratch space variable
> //   named "arrival". The first argument is value of the name attribute of the
> //   <data> element and the second is the String value of the XPath
> //   expression. If more than one matching nodes are found, the first one
> //   is returned.   //this is different from your current implementation which uses data elements associated with a state e.g.
>     <scxml xmlns="http://www.w3.org/2005/07/scxml"
>               version="1.0"
>               initialstate="airline-ticket">
>
>      <state id="airline-ticket">
>        <datamodel>
>          <data...>
> the association of this data would be to airline-ticket and could not be used in hotel or restaurant
> a complete scxml tutorial is available at
> http://commons.apache.org/scxml/guide/datamodel.html
>
> HTH
> Martin Gainty
> ______________________________________________
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
>
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
>
>
>
>
>> From: fmorbini@gmail.com
>> Date: Thu, 6 May 2010 10:24:17 -0700
>> Subject: Re: [scxml] templating/src/xinclude and returning a value(through    datamodel/donedata)
>> To: user@commons.apache.org
>>
>> Hi Rahul, thanks for the quick reply. i opened the JIRA ticket for the
>> donedata as you suggested.
>> But i still cannot get this to work even with your suggested
>> modifications. Here is the log of execution (it seems that the
>> assignment to AAA doesn't persist).
>>
>> DEBUG 10:14:22.086 [Thread-1       ] [sax                      ] endDocument()
>> DEBUG 10:14:23.103 [Thread-1       ] [Context                  ]
>> _ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
>> cs=http://commons.apache.org/scxml}
>> DEBUG 10:14:23.129 [Thread-1       ] [ExpressionFactory        ]
>> Parsing expression: 10;
>> DEBUG 10:14:23.131 [Thread-1       ] [Context                  ]
>> _ALL_NAMESPACES = null
>> DEBUG 10:14:23.131 [Thread-1       ] [Context                  ] cook_time = 10
>> DEBUG 10:14:23.131 [Thread-1       ] [Context                  ] AAA =
>> [data: null]
>> DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
>> _eventdata = null
>> DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
>> _eventdatamap = {s1.entry=null}
>> DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
>> _eventdata = null
>> DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
>> _eventdatamap = {s11.entry=null, s1.exit=null, s2.entry=null}
>> DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
>> _ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
>> cs=http://commons.apache.org/scxml}
>> DEBUG 10:14:23.133 [Thread-1       ] [ExpressionFactory        ]
>> Parsing expression: AAA;
>> DEBUG 10:14:23.133 [Thread-1       ] [ExpressionFactory        ]
>> Parsing expression: 's3';
>> DEBUG 10:14:23.134 [Thread-1       ] [ExpressionFactory        ]
>> Parsing expression: 's3';
>> DEBUG 10:14:23.134 [Thread-1       ] [SCXMLSemantics           ]
>> <assign>: data node 'data' updated
>> DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
>> _ALL_NAMESPACES = null
>> DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
>> _eventdata = null
>> DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
>> _eventdatamap = {s11.exit=null, s12.entry=null, null.change=null,
>> s2.done=null}
>> DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
>> _ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
>> cs=http://commons.apache.org/scxml}
>> DEBUG 10:14:23.134 [Thread-1       ] [ExpressionFactory        ]
>> Parsing expression: AAA eq 's3';
>> DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
>> _ALL_NAMESPACES = null
>> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
>> _ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
>> cs=http://commons.apache.org/scxml}
>> DEBUG 10:14:23.135 [Thread-1       ] [ExpressionFactory        ]
>> Parsing expression: AAA eq 's4';
>> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
>> _ALL_NAMESPACES = null
>> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
>> _ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
>> cs=http://commons.apache.org/scxml}
>> DEBUG 10:14:23.135 [Thread-1       ] [ExpressionFactory        ]
>> Parsing expression: AAA;
>> INFO  10:14:23.135 [Thread-1       ] [SCXMLSemantics           ] null:
>> [data: null]
>> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
>> _ALL_NAMESPACES = null
>> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
>> _eventdata = null
>> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
>> _eventdatamap = {s2.exit=null, s12.exit=null, s5.entry=null,
>> .done=null}
>> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
>> _eventdata = null
>> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
>> _eventdatamap = {s1.entry=null}
>> DEBUG 10:14:23.135 [Thread-1       ] [SCXMLExecutor            ]
>> Current States: [s5]
>>
>> here are the modified files:
>> =============file a.scxml=====================================
>> <?xml version="1.0"?>
>> <scxml xmlns="http://www.w3.org/2005/07/scxml"
>>               xmlns:cs="http://commons.apache.org/scxml"
>>        version="1.0"
>>        profile="ecmascript"
>>        initial="s1">
>>
>>   <!--  trivial 5 second microwave oven example -->
>>   <!--  see http://commons.apache.org/scxml/guide/datamodel.html for
>> different way to access the datamodel -->
>>   <datamodel>
>>     <data id="cook_time" expr="10"/>
>>        <data id="AAA" expr="''"/>
>>   </datamodel>
>>
>>   <state id="s1">
>>     <!-- off state -->
>>     <transition target="s2"/>
>>   </state>
>>
>>   <state id="s2" src="b.scxml#s111">
>>
>>     <!-- on/pause state -->
>>
>>     <transition event="s2.done" cond="AAA eq 's3'" target="s3"/>
>>     <transition event="s2.done" cond="AAA eq 's4'" target="s4"/>
>>     <transition event="s2.done" target="s5"/>
>>       <onexit>
>>               <log expr="AAA"/>
>>       </onexit>
>>   </state>
>>
>>     <final id="s3"/>
>>     <final id="s4"/>
>>     <final id="s5"/>
>> </scxml>
>> =============end of file a.scxml==============================
>>
>> =============file b.scxml=====================================
>> <?xml version="1.0" encoding="us-ascii"?>
>> <scxml version="1.0" xmlns="http://www.w3.org/2005/07/scxml"
>> xmlns:cs="http://commons.apache.org/scxml" initial="s111">
>>       <state id="s111">
>>       <initial><transition target="s11"/></initial>
>>
>>     <state id="s11">
>>               <transition target="s12">
>>                               <!--<cs:var name="aaa" expr="'s3'" />-->
>>                               <assign location="AAA" expr="'s3'"/>
>>               </transition>
>>     </state>
>>
>>       <final id="s12">
>>       </final>
>>       </state>
>> </scxml>
>> =============end of file b.scxml==============================
>>
>> thanks,
>> fabrizio.
>>
>> On Thu, May 6, 2010 at 09:52, Rahul Akolkar <ra...@gmail.com> wrote:
>> > On Thu, May 6, 2010 at 11:34 AM, Fabrizio Morbini <fm...@gmail.com> wrote:
>> >> Hi, i'm experimenting with the src attribute to reuse fsm. I'm having
>> >> some trouble with returning a value from an included fsm to the
>> >> calling state.
>> >>
>> >> I'm using this description at
>> >> http://shale.apache.org/shale-dialog-scxml/index.html, in particular
>> >> the section about subdialogs from which it seems possible to return a
>> >> value from an included scxml fsm.
>> >> However i have been unable to do so. I've tried several variants but
>> >> none with the expected outcome.
>> > <snip/>
>> >
>> > The Commons SCXML v0.9 release does not use a flat / global datamodel
>> > by default, therefore the value would need to be copied up to a
>> > datamodel with a superior position in the states topology (such as
>> > document root to be available across any other state). I will outline
>> > this approach using your example below.
>> >
>> > Alternatively, provide the SCXMLExecutor with a custom Evaluator
>> > implementation that returns the same context (the root context) on
>> > every Evaluator#newContext() call to obtain a flat datamodel. If you
>> > do this, there would be no changes required to the example below.
>> >
>> > Now, for the first approach with the default cascading datamodel, see below:
>> >
>> >
>> >> Here is the current variant:
>> >>
>> >> =============file a.scxml=====================================
>> >> <?xml version="1.0"?>
>> >> <scxml xmlns="http://www.w3.org/2005/07/scxml"
>> >>                xmlns:cs="http://commons.apache.org/scxml"
>> >>       version="1.0"
>> >>       profile="ecmascript"
>> >>       initial="s1">
>> >>
>> >>  <!--  trivial 5 second microwave oven example -->
>> >>  <!--  see http://commons.apache.org/scxml/guide/datamodel.html for
>> >> different way to access the datamodel -->
>> >>  <datamodel>
>> >>    <data id="cook_time" expr="10"/>
>> > <snap/>
>> >
>> > Define a global 'aaa' variable here, say like so (note different case
>> > used here, i.e. chose a different name of choice):
>> >
>> >     <data id="AAA" />
>> >
>> >
>> >>  </datamodel>
>> >>
>> >>  <state id="s1">
>> >>    <!-- off state -->
>> >>    <transition target="s2"/>
>> >>  </state>
>> >>
>> >>  <state id="s2" src="b.scxml#s111">
>> >>
>> >>    <!-- on/pause state -->
>> >>
>> >>    <transition event="s2.done" cond="aaa eq 's3'" target="s3"/>
>> >>    <transition event="s2.done" cond="aaa eq 's4'" target="s4"/>
>> >>    <transition event="s2.done" target="s5"/>
>> >>
>> >>  </state>
>> >>
>> >>    <final id="s3"/>
>> >>    <final id="s4"/>
>> >>    <final id="s5"/>
>> >> </scxml>
>> >> =============end of file a.scxml==============================
>> >>
>> >> =============file b.scxml=====================================
>> >> <?xml version="1.0" encoding="us-ascii"?>
>> >> <scxml version="1.0" xmlns="http://www.w3.org/2005/07/scxml"
>> >> xmlns:cs="http://commons.apache.org/scxml" initial="s111">
>> >>        <state id="s111">
>> >>        <initial><transition target="s11"/></initial>
>> >>        <datamodel><data id="aaa"/></datamodel>
>> >>
>> >>    <state id="s11">
>> >>                <transition target="s12">
>> >>                                <!--<cs:var name="aaa" expr="'s3'" />-->
>> >>                                <assign location="aaa" expr="'s3'"/>
>> > <snip/>
>> >
>> > Change the above to point to the variable defined in the parent
>> > document above like so:
>> >
>> >         <assign location="AAA" expr="'s3'"/>
>> >
>> > Obviously, this would imply that b.scxml could only be executed when
>> > included in a.scxml since it references a datamodel variable in
>> > a.scxml. If that is not desired, the second approach i.e. the flat
>> > datamodel approach should be used.
>> >
>> >
>> >>                </transition>
>> >>    </state>
>> >>
>> >>        <final id="s12">
>> >>        </final>
>> >>        </state>
>> >> </scxml>
>> >> =============end of file b.scxml==============================
>> >>
>> >> i tried to use also <var> instead of a previously defined variable in
>> >> the datamodel, without success.
>> >>
>> >> the simple way would be to use the donedata in a final state in the
>> >> included fsm but it doesn't seem that donedata is supported, is this
>> >> correct?
>> >>
>> > <snap/>
>> >
>> > Yes, not in v0.9, we will look to add it soon. You could open a JIRA
>> > issue as a reminder.
>> >
>> >
>> >> given that src is not going to be supported in the next standard, do
>> >> you have some pointer to examples/doc of how to use xinclude to do
>> >> what the src is supposed to do?
>> >>
>> > <snip/>
>> >
>> > Don't have a ready example, but the idea is to pull in as much of the
>> > document as needs to be reused using XInclude. See XInclude
>> > specification for more details. It certain cases, the XInclude
>> > approach requires more work but is favored since its a standard way to
>> > do includes.
>> >
>> > -Rahul
>> >
>> >
>> >> thanks,
>> >> fabrizio.
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> > For additional commands, e-mail: user-help@commons.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>
> _________________________________________________________________
> The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail.
> http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


RE: [scxml] templating/src/xinclude and returning a value(through datamodel/donedata)

Posted by Martin Gainty <mg...@hotmail.com>.
Fabrizio-

from what ive read in the scxml doc you need to configure the datamodel and their respective data node children directly under the scm root node e.g.
<scxml xmlns="http://www.w3.org/2005/07/scxml"
               version="1.0"
               initialstate="init-travel-plan">

      <datamodel>
        <data name="airlineticket">
//you can use the Data macro to reference the current value of the requested parameters e.g.
//Commons SCXML defines a Data()
   function for use in JEXL or EL expressions, for example:
    <var name="arrival" expr="Data(hotelbooking, 'hotel/stay/arrival')" />

//   The above expression extracts the arrival date from the hotelbooking
//   data in the documents datamodel and stores it in a scratch space variable
//   named "arrival". The first argument is value of the name attribute of the
//   <data> element and the second is the String value of the XPath
//   expression. If more than one matching nodes are found, the first one
//   is returned.   //this is different from your current implementation which uses data elements associated with a state e.g.
     <scxml xmlns="http://www.w3.org/2005/07/scxml"
               version="1.0"
               initialstate="airline-ticket">

      <state id="airline-ticket">
        <datamodel>
          <data...>
the association of this data would be to airline-ticket and could not be used in hotel or restaurant
a complete scxml tutorial is available at
http://commons.apache.org/scxml/guide/datamodel.html

HTH
Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> From: fmorbini@gmail.com
> Date: Thu, 6 May 2010 10:24:17 -0700
> Subject: Re: [scxml] templating/src/xinclude and returning a value(through 	datamodel/donedata)
> To: user@commons.apache.org
> 
> Hi Rahul, thanks for the quick reply. i opened the JIRA ticket for the
> donedata as you suggested.
> But i still cannot get this to work even with your suggested
> modifications. Here is the log of execution (it seems that the
> assignment to AAA doesn't persist).
> 
> DEBUG 10:14:22.086 [Thread-1       ] [sax                      ] endDocument()
> DEBUG 10:14:23.103 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
> cs=http://commons.apache.org/scxml}
> DEBUG 10:14:23.129 [Thread-1       ] [ExpressionFactory        ]
> Parsing expression: 10;
> DEBUG 10:14:23.131 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = null
> DEBUG 10:14:23.131 [Thread-1       ] [Context                  ] cook_time = 10
> DEBUG 10:14:23.131 [Thread-1       ] [Context                  ] AAA =
> [data: null]
> DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
> _eventdata = null
> DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
> _eventdatamap = {s1.entry=null}
> DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
> _eventdata = null
> DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
> _eventdatamap = {s11.entry=null, s1.exit=null, s2.entry=null}
> DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
> cs=http://commons.apache.org/scxml}
> DEBUG 10:14:23.133 [Thread-1       ] [ExpressionFactory        ]
> Parsing expression: AAA;
> DEBUG 10:14:23.133 [Thread-1       ] [ExpressionFactory        ]
> Parsing expression: 's3';
> DEBUG 10:14:23.134 [Thread-1       ] [ExpressionFactory        ]
> Parsing expression: 's3';
> DEBUG 10:14:23.134 [Thread-1       ] [SCXMLSemantics           ]
> <assign>: data node 'data' updated
> DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = null
> DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
> _eventdata = null
> DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
> _eventdatamap = {s11.exit=null, s12.entry=null, null.change=null,
> s2.done=null}
> DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
> cs=http://commons.apache.org/scxml}
> DEBUG 10:14:23.134 [Thread-1       ] [ExpressionFactory        ]
> Parsing expression: AAA eq 's3';
> DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = null
> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
> cs=http://commons.apache.org/scxml}
> DEBUG 10:14:23.135 [Thread-1       ] [ExpressionFactory        ]
> Parsing expression: AAA eq 's4';
> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = null
> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
> cs=http://commons.apache.org/scxml}
> DEBUG 10:14:23.135 [Thread-1       ] [ExpressionFactory        ]
> Parsing expression: AAA;
> INFO  10:14:23.135 [Thread-1       ] [SCXMLSemantics           ] null:
> [data: null]
> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = null
> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
> _eventdata = null
> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
> _eventdatamap = {s2.exit=null, s12.exit=null, s5.entry=null,
> .done=null}
> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
> _eventdata = null
> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
> _eventdatamap = {s1.entry=null}
> DEBUG 10:14:23.135 [Thread-1       ] [SCXMLExecutor            ]
> Current States: [s5]
> 
> here are the modified files:
> =============file a.scxml=====================================
> <?xml version="1.0"?>
> <scxml xmlns="http://www.w3.org/2005/07/scxml"
> 		xmlns:cs="http://commons.apache.org/scxml"
>        version="1.0"
>        profile="ecmascript"
>        initial="s1">
> 
>   <!--  trivial 5 second microwave oven example -->
>   <!--  see http://commons.apache.org/scxml/guide/datamodel.html for
> different way to access the datamodel -->
>   <datamodel>
>     <data id="cook_time" expr="10"/>
> 	 <data id="AAA" expr="''"/>
>   </datamodel>
> 
>   <state id="s1">
>     <!-- off state -->
>     <transition target="s2"/>
>   </state>
> 
>   <state id="s2" src="b.scxml#s111">
> 
>     <!-- on/pause state -->
> 	
>     <transition event="s2.done" cond="AAA eq 's3'" target="s3"/>
>     <transition event="s2.done" cond="AAA eq 's4'" target="s4"/>
>     <transition event="s2.done" target="s5"/>
> 	<onexit>
> 		<log expr="AAA"/>
> 	</onexit>
>   </state>
> 
>     <final id="s3"/>
>     <final id="s4"/>
>     <final id="s5"/>
> </scxml>
> =============end of file a.scxml==============================
> 
> =============file b.scxml=====================================
> <?xml version="1.0" encoding="us-ascii"?>
> <scxml version="1.0" xmlns="http://www.w3.org/2005/07/scxml"
> xmlns:cs="http://commons.apache.org/scxml" initial="s111">
> 	<state id="s111">
> 	<initial><transition target="s11"/></initial>
> 
>     <state id="s11">
> 		<transition target="s12">
> 				<!--<cs:var name="aaa" expr="'s3'" />-->
> 				<assign location="AAA" expr="'s3'"/>
> 		</transition>
>     </state>
> 
> 	<final id="s12">
> 	</final>
> 	</state>
> </scxml>
> =============end of file b.scxml==============================
> 
> thanks,
> fabrizio.
> 
> On Thu, May 6, 2010 at 09:52, Rahul Akolkar <ra...@gmail.com> wrote:
> > On Thu, May 6, 2010 at 11:34 AM, Fabrizio Morbini <fm...@gmail.com> wrote:
> >> Hi, i'm experimenting with the src attribute to reuse fsm. I'm having
> >> some trouble with returning a value from an included fsm to the
> >> calling state.
> >>
> >> I'm using this description at
> >> http://shale.apache.org/shale-dialog-scxml/index.html, in particular
> >> the section about subdialogs from which it seems possible to return a
> >> value from an included scxml fsm.
> >> However i have been unable to do so. I've tried several variants but
> >> none with the expected outcome.
> > <snip/>
> >
> > The Commons SCXML v0.9 release does not use a flat / global datamodel
> > by default, therefore the value would need to be copied up to a
> > datamodel with a superior position in the states topology (such as
> > document root to be available across any other state). I will outline
> > this approach using your example below.
> >
> > Alternatively, provide the SCXMLExecutor with a custom Evaluator
> > implementation that returns the same context (the root context) on
> > every Evaluator#newContext() call to obtain a flat datamodel. If you
> > do this, there would be no changes required to the example below.
> >
> > Now, for the first approach with the default cascading datamodel, see below:
> >
> >
> >> Here is the current variant:
> >>
> >> =============file a.scxml=====================================
> >> <?xml version="1.0"?>
> >> <scxml xmlns="http://www.w3.org/2005/07/scxml"
> >>                xmlns:cs="http://commons.apache.org/scxml"
> >>       version="1.0"
> >>       profile="ecmascript"
> >>       initial="s1">
> >>
> >>  <!--  trivial 5 second microwave oven example -->
> >>  <!--  see http://commons.apache.org/scxml/guide/datamodel.html for
> >> different way to access the datamodel -->
> >>  <datamodel>
> >>    <data id="cook_time" expr="10"/>
> > <snap/>
> >
> > Define a global 'aaa' variable here, say like so (note different case
> > used here, i.e. chose a different name of choice):
> >
> >     <data id="AAA" />
> >
> >
> >>  </datamodel>
> >>
> >>  <state id="s1">
> >>    <!-- off state -->
> >>    <transition target="s2"/>
> >>  </state>
> >>
> >>  <state id="s2" src="b.scxml#s111">
> >>
> >>    <!-- on/pause state -->
> >>
> >>    <transition event="s2.done" cond="aaa eq 's3'" target="s3"/>
> >>    <transition event="s2.done" cond="aaa eq 's4'" target="s4"/>
> >>    <transition event="s2.done" target="s5"/>
> >>
> >>  </state>
> >>
> >>    <final id="s3"/>
> >>    <final id="s4"/>
> >>    <final id="s5"/>
> >> </scxml>
> >> =============end of file a.scxml==============================
> >>
> >> =============file b.scxml=====================================
> >> <?xml version="1.0" encoding="us-ascii"?>
> >> <scxml version="1.0" xmlns="http://www.w3.org/2005/07/scxml"
> >> xmlns:cs="http://commons.apache.org/scxml" initial="s111">
> >>        <state id="s111">
> >>        <initial><transition target="s11"/></initial>
> >>        <datamodel><data id="aaa"/></datamodel>
> >>
> >>    <state id="s11">
> >>                <transition target="s12">
> >>                                <!--<cs:var name="aaa" expr="'s3'" />-->
> >>                                <assign location="aaa" expr="'s3'"/>
> > <snip/>
> >
> > Change the above to point to the variable defined in the parent
> > document above like so:
> >
> >         <assign location="AAA" expr="'s3'"/>
> >
> > Obviously, this would imply that b.scxml could only be executed when
> > included in a.scxml since it references a datamodel variable in
> > a.scxml. If that is not desired, the second approach i.e. the flat
> > datamodel approach should be used.
> >
> >
> >>                </transition>
> >>    </state>
> >>
> >>        <final id="s12">
> >>        </final>
> >>        </state>
> >> </scxml>
> >> =============end of file b.scxml==============================
> >>
> >> i tried to use also <var> instead of a previously defined variable in
> >> the datamodel, without success.
> >>
> >> the simple way would be to use the donedata in a final state in the
> >> included fsm but it doesn't seem that donedata is supported, is this
> >> correct?
> >>
> > <snap/>
> >
> > Yes, not in v0.9, we will look to add it soon. You could open a JIRA
> > issue as a reminder.
> >
> >
> >> given that src is not going to be supported in the next standard, do
> >> you have some pointer to examples/doc of how to use xinclude to do
> >> what the src is supposed to do?
> >>
> > <snip/>
> >
> > Don't have a ready example, but the idea is to pull in as much of the
> > document as needs to be reused using XInclude. See XInclude
> > specification for more details. It certain cases, the XInclude
> > approach requires more work but is favored since its a standard way to
> > do includes.
> >
> > -Rahul
> >
> >
> >> thanks,
> >> fabrizio.
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> > For additional commands, e-mail: user-help@commons.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
 		 	   		  
_________________________________________________________________
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail. 
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5

Re: [scxml] templating/src/xinclude and returning a value(through datamodel/donedata)

Posted by Rahul Akolkar <ra...@gmail.com>.
On Thu, May 6, 2010 at 1:57 PM, Fabrizio Morbini <fm...@gmail.com> wrote:
> On Thu, May 6, 2010 at 10:37, Rahul Akolkar <ra...@gmail.com> wrote:
>> Ah, too much cut and paste. Since this assignment isn't necessarily
>> using a location expression, use:
>>
>>  <assign name="AAA" expr="'s3'"/>
>>
>> For details, see:
>>
>>  http://commons.apache.org/scxml/guide/datamodel.html#assign
>>
>> Alternatively, the <data> could be made to store XML content (like the
>> travel reservation example at the above URL), and the location
>> attribute could then be used in a portable way.
>
> using name= instead of location= solves the problem.
>
> however it's not clear to me why it solves the problem (i did read the
> doc page you pointed at). From the doc:
> using name is for: "Assigning to a scratch space variable"
> using location is for "Assigning a literal to a data subtree"
>
<snip/>

A more clear distinction is whether or not the <data> is a atomic
literal (string) or has substructure (such as an XML tree underneath).
The above talks about scratch space variables in the context of
<cs:var> (but is more generally about data items that have no
substructure, which is how the legacy <cs:var> is stored internally as
well).


> our case here is the second, however the one that works is the first.
> If we want to assign to a <data> item that is inherited from a parent
> scxml file, why do we have to use name instead of location?
>
<snap/>

See above.


> finally, what do you mean with your last paragraph? (in particular
> with: "and the location attribute could then be used in a portable
> way", do you mean that there is a way to decouple b.scxml from being
> usable only in a.scxml (or anything providing a <data> item named AAA)
> if the link AAA is implemented as xml as in the reservation example?)
>
<snip/>

In a way. I meant to say the following usage is portable across SCXML
implementations:

  <assign location="..." expr="..."/>

whereas the following is not (though the first WD of SCXML supported
it, and we retain the ability to use it in scenarios mentioned before
for backwards compatibility of Commons SCXML):

  <assign name="..." expr="..."/>

So restructuring the <data> to contain substructure and then using the
former location pattern makes it current practice.

-Rahul


> thanks again.
>
> best,
> fabrizio.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [scxml] templating/src/xinclude and returning a value(through datamodel/donedata)

Posted by Fabrizio Morbini <fm...@gmail.com>.
On Thu, May 6, 2010 at 10:37, Rahul Akolkar <ra...@gmail.com> wrote:
> Ah, too much cut and paste. Since this assignment isn't necessarily
> using a location expression, use:
>
>  <assign name="AAA" expr="'s3'"/>
>
> For details, see:
>
>  http://commons.apache.org/scxml/guide/datamodel.html#assign
>
> Alternatively, the <data> could be made to store XML content (like the
> travel reservation example at the above URL), and the location
> attribute could then be used in a portable way.

using name= instead of location= solves the problem.

however it's not clear to me why it solves the problem (i did read the
doc page you pointed at). From the doc:
using name is for: "Assigning to a scratch space variable"
using location is for "Assigning a literal to a data subtree"

our case here is the second, however the one that works is the first.
If we want to assign to a <data> item that is inherited from a parent
scxml file, why do we have to use name instead of location?

finally, what do you mean with your last paragraph? (in particular
with: "and the location attribute could then be used in a portable
way", do you mean that there is a way to decouple b.scxml from being
usable only in a.scxml (or anything providing a <data> item named AAA)
if the link AAA is implemented as xml as in the reservation example?)

thanks again.

best,
fabrizio.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [scxml] templating/src/xinclude and returning a value(through datamodel/donedata)

Posted by Rahul Akolkar <ra...@gmail.com>.
On Thu, May 6, 2010 at 1:24 PM, Fabrizio Morbini <fm...@gmail.com> wrote:
> Hi Rahul, thanks for the quick reply. i opened the JIRA ticket for the
> donedata as you suggested.
> But i still cannot get this to work even with your suggested
> modifications. Here is the log of execution (it seems that the
> assignment to AAA doesn't persist).
>
<snip/>

Ah, too much cut and paste. Since this assignment isn't necessarily
using a location expression, use:

  <assign name="AAA" expr="'s3'"/>

For details, see:

  http://commons.apache.org/scxml/guide/datamodel.html#assign

Alternatively, the <data> could be made to store XML content (like the
travel reservation example at the above URL), and the location
attribute could then be used in a portable way.

-Rahul


> DEBUG 10:14:22.086 [Thread-1       ] [sax                      ] endDocument()
> DEBUG 10:14:23.103 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
> cs=http://commons.apache.org/scxml}
> DEBUG 10:14:23.129 [Thread-1       ] [ExpressionFactory        ]
> Parsing expression: 10;
> DEBUG 10:14:23.131 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = null
> DEBUG 10:14:23.131 [Thread-1       ] [Context                  ] cook_time = 10
> DEBUG 10:14:23.131 [Thread-1       ] [Context                  ] AAA =
> [data: null]
> DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
> _eventdata = null
> DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
> _eventdatamap = {s1.entry=null}
> DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
> _eventdata = null
> DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
> _eventdatamap = {s11.entry=null, s1.exit=null, s2.entry=null}
> DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
> cs=http://commons.apache.org/scxml}
> DEBUG 10:14:23.133 [Thread-1       ] [ExpressionFactory        ]
> Parsing expression: AAA;
> DEBUG 10:14:23.133 [Thread-1       ] [ExpressionFactory        ]
> Parsing expression: 's3';
> DEBUG 10:14:23.134 [Thread-1       ] [ExpressionFactory        ]
> Parsing expression: 's3';
> DEBUG 10:14:23.134 [Thread-1       ] [SCXMLSemantics           ]
> <assign>: data node 'data' updated
> DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = null
> DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
> _eventdata = null
> DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
> _eventdatamap = {s11.exit=null, s12.entry=null, null.change=null,
> s2.done=null}
> DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
> cs=http://commons.apache.org/scxml}
> DEBUG 10:14:23.134 [Thread-1       ] [ExpressionFactory        ]
> Parsing expression: AAA eq 's3';
> DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = null
> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
> cs=http://commons.apache.org/scxml}
> DEBUG 10:14:23.135 [Thread-1       ] [ExpressionFactory        ]
> Parsing expression: AAA eq 's4';
> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = null
> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
> cs=http://commons.apache.org/scxml}
> DEBUG 10:14:23.135 [Thread-1       ] [ExpressionFactory        ]
> Parsing expression: AAA;
> INFO  10:14:23.135 [Thread-1       ] [SCXMLSemantics           ] null:
> [data: null]
> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
> _ALL_NAMESPACES = null
> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
> _eventdata = null
> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
> _eventdatamap = {s2.exit=null, s12.exit=null, s5.entry=null,
> .done=null}
> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
> _eventdata = null
> DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
> _eventdatamap = {s1.entry=null}
> DEBUG 10:14:23.135 [Thread-1       ] [SCXMLExecutor            ]
> Current States: [s5]
>
> here are the modified files:
> =============file a.scxml=====================================
> <?xml version="1.0"?>
> <scxml xmlns="http://www.w3.org/2005/07/scxml"
>                xmlns:cs="http://commons.apache.org/scxml"
>       version="1.0"
>       profile="ecmascript"
>       initial="s1">
>
>  <!--  trivial 5 second microwave oven example -->
>  <!--  see http://commons.apache.org/scxml/guide/datamodel.html for
> different way to access the datamodel -->
>  <datamodel>
>    <data id="cook_time" expr="10"/>
>         <data id="AAA" expr="''"/>
>  </datamodel>
>
>  <state id="s1">
>    <!-- off state -->
>    <transition target="s2"/>
>  </state>
>
>  <state id="s2" src="b.scxml#s111">
>
>    <!-- on/pause state -->
>
>    <transition event="s2.done" cond="AAA eq 's3'" target="s3"/>
>    <transition event="s2.done" cond="AAA eq 's4'" target="s4"/>
>    <transition event="s2.done" target="s5"/>
>        <onexit>
>                <log expr="AAA"/>
>        </onexit>
>  </state>
>
>    <final id="s3"/>
>    <final id="s4"/>
>    <final id="s5"/>
> </scxml>
> =============end of file a.scxml==============================
>
> =============file b.scxml=====================================
> <?xml version="1.0" encoding="us-ascii"?>
> <scxml version="1.0" xmlns="http://www.w3.org/2005/07/scxml"
> xmlns:cs="http://commons.apache.org/scxml" initial="s111">
>        <state id="s111">
>        <initial><transition target="s11"/></initial>
>
>    <state id="s11">
>                <transition target="s12">
>                                <!--<cs:var name="aaa" expr="'s3'" />-->
>                                <assign location="AAA" expr="'s3'"/>
>                </transition>
>    </state>
>
>        <final id="s12">
>        </final>
>        </state>
> </scxml>
> =============end of file b.scxml==============================
>
> thanks,
> fabrizio.
>
> On Thu, May 6, 2010 at 09:52, Rahul Akolkar <ra...@gmail.com> wrote:
>> On Thu, May 6, 2010 at 11:34 AM, Fabrizio Morbini <fm...@gmail.com> wrote:
>>> Hi, i'm experimenting with the src attribute to reuse fsm. I'm having
>>> some trouble with returning a value from an included fsm to the
>>> calling state.
>>>
>>> I'm using this description at
>>> http://shale.apache.org/shale-dialog-scxml/index.html, in particular
>>> the section about subdialogs from which it seems possible to return a
>>> value from an included scxml fsm.
>>> However i have been unable to do so. I've tried several variants but
>>> none with the expected outcome.
>> <snip/>
>>
>> The Commons SCXML v0.9 release does not use a flat / global datamodel
>> by default, therefore the value would need to be copied up to a
>> datamodel with a superior position in the states topology (such as
>> document root to be available across any other state). I will outline
>> this approach using your example below.
>>
>> Alternatively, provide the SCXMLExecutor with a custom Evaluator
>> implementation that returns the same context (the root context) on
>> every Evaluator#newContext() call to obtain a flat datamodel. If you
>> do this, there would be no changes required to the example below.
>>
>> Now, for the first approach with the default cascading datamodel, see below:
>>
>>
>>> Here is the current variant:
>>>
>>> =============file a.scxml=====================================
>>> <?xml version="1.0"?>
>>> <scxml xmlns="http://www.w3.org/2005/07/scxml"
>>>                xmlns:cs="http://commons.apache.org/scxml"
>>>       version="1.0"
>>>       profile="ecmascript"
>>>       initial="s1">
>>>
>>>  <!--  trivial 5 second microwave oven example -->
>>>  <!--  see http://commons.apache.org/scxml/guide/datamodel.html for
>>> different way to access the datamodel -->
>>>  <datamodel>
>>>    <data id="cook_time" expr="10"/>
>> <snap/>
>>
>> Define a global 'aaa' variable here, say like so (note different case
>> used here, i.e. chose a different name of choice):
>>
>>     <data id="AAA" />
>>
>>
>>>  </datamodel>
>>>
>>>  <state id="s1">
>>>    <!-- off state -->
>>>    <transition target="s2"/>
>>>  </state>
>>>
>>>  <state id="s2" src="b.scxml#s111">
>>>
>>>    <!-- on/pause state -->
>>>
>>>    <transition event="s2.done" cond="aaa eq 's3'" target="s3"/>
>>>    <transition event="s2.done" cond="aaa eq 's4'" target="s4"/>
>>>    <transition event="s2.done" target="s5"/>
>>>
>>>  </state>
>>>
>>>    <final id="s3"/>
>>>    <final id="s4"/>
>>>    <final id="s5"/>
>>> </scxml>
>>> =============end of file a.scxml==============================
>>>
>>> =============file b.scxml=====================================
>>> <?xml version="1.0" encoding="us-ascii"?>
>>> <scxml version="1.0" xmlns="http://www.w3.org/2005/07/scxml"
>>> xmlns:cs="http://commons.apache.org/scxml" initial="s111">
>>>        <state id="s111">
>>>        <initial><transition target="s11"/></initial>
>>>        <datamodel><data id="aaa"/></datamodel>
>>>
>>>    <state id="s11">
>>>                <transition target="s12">
>>>                                <!--<cs:var name="aaa" expr="'s3'" />-->
>>>                                <assign location="aaa" expr="'s3'"/>
>> <snip/>
>>
>> Change the above to point to the variable defined in the parent
>> document above like so:
>>
>>         <assign location="AAA" expr="'s3'"/>
>>
>> Obviously, this would imply that b.scxml could only be executed when
>> included in a.scxml since it references a datamodel variable in
>> a.scxml. If that is not desired, the second approach i.e. the flat
>> datamodel approach should be used.
>>
>>
>>>                </transition>
>>>    </state>
>>>
>>>        <final id="s12">
>>>        </final>
>>>        </state>
>>> </scxml>
>>> =============end of file b.scxml==============================
>>>
>>> i tried to use also <var> instead of a previously defined variable in
>>> the datamodel, without success.
>>>
>>> the simple way would be to use the donedata in a final state in the
>>> included fsm but it doesn't seem that donedata is supported, is this
>>> correct?
>>>
>> <snap/>
>>
>> Yes, not in v0.9, we will look to add it soon. You could open a JIRA
>> issue as a reminder.
>>
>>
>>> given that src is not going to be supported in the next standard, do
>>> you have some pointer to examples/doc of how to use xinclude to do
>>> what the src is supposed to do?
>>>
>> <snip/>
>>
>> Don't have a ready example, but the idea is to pull in as much of the
>> document as needs to be reused using XInclude. See XInclude
>> specification for more details. It certain cases, the XInclude
>> approach requires more work but is favored since its a standard way to
>> do includes.
>>
>> -Rahul
>>
>>
>>> thanks,
>>> fabrizio.
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [scxml] templating/src/xinclude and returning a value(through datamodel/donedata)

Posted by Fabrizio Morbini <fm...@gmail.com>.
Hi Rahul, thanks for the quick reply. i opened the JIRA ticket for the
donedata as you suggested.
But i still cannot get this to work even with your suggested
modifications. Here is the log of execution (it seems that the
assignment to AAA doesn't persist).

DEBUG 10:14:22.086 [Thread-1       ] [sax                      ] endDocument()
DEBUG 10:14:23.103 [Thread-1       ] [Context                  ]
_ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
cs=http://commons.apache.org/scxml}
DEBUG 10:14:23.129 [Thread-1       ] [ExpressionFactory        ]
Parsing expression: 10;
DEBUG 10:14:23.131 [Thread-1       ] [Context                  ]
_ALL_NAMESPACES = null
DEBUG 10:14:23.131 [Thread-1       ] [Context                  ] cook_time = 10
DEBUG 10:14:23.131 [Thread-1       ] [Context                  ] AAA =
[data: null]
DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
_eventdata = null
DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
_eventdatamap = {s1.entry=null}
DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
_eventdata = null
DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
_eventdatamap = {s11.entry=null, s1.exit=null, s2.entry=null}
DEBUG 10:14:23.132 [Thread-1       ] [Context                  ]
_ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
cs=http://commons.apache.org/scxml}
DEBUG 10:14:23.133 [Thread-1       ] [ExpressionFactory        ]
Parsing expression: AAA;
DEBUG 10:14:23.133 [Thread-1       ] [ExpressionFactory        ]
Parsing expression: 's3';
DEBUG 10:14:23.134 [Thread-1       ] [ExpressionFactory        ]
Parsing expression: 's3';
DEBUG 10:14:23.134 [Thread-1       ] [SCXMLSemantics           ]
<assign>: data node 'data' updated
DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
_ALL_NAMESPACES = null
DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
_eventdata = null
DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
_eventdatamap = {s11.exit=null, s12.entry=null, null.change=null,
s2.done=null}
DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
_ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
cs=http://commons.apache.org/scxml}
DEBUG 10:14:23.134 [Thread-1       ] [ExpressionFactory        ]
Parsing expression: AAA eq 's3';
DEBUG 10:14:23.134 [Thread-1       ] [Context                  ]
_ALL_NAMESPACES = null
DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
_ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
cs=http://commons.apache.org/scxml}
DEBUG 10:14:23.135 [Thread-1       ] [ExpressionFactory        ]
Parsing expression: AAA eq 's4';
DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
_ALL_NAMESPACES = null
DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
_ALL_NAMESPACES = {=http://www.w3.org/2005/07/scxml,
cs=http://commons.apache.org/scxml}
DEBUG 10:14:23.135 [Thread-1       ] [ExpressionFactory        ]
Parsing expression: AAA;
INFO  10:14:23.135 [Thread-1       ] [SCXMLSemantics           ] null:
[data: null]
DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
_ALL_NAMESPACES = null
DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
_eventdata = null
DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
_eventdatamap = {s2.exit=null, s12.exit=null, s5.entry=null,
.done=null}
DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
_eventdata = null
DEBUG 10:14:23.135 [Thread-1       ] [Context                  ]
_eventdatamap = {s1.entry=null}
DEBUG 10:14:23.135 [Thread-1       ] [SCXMLExecutor            ]
Current States: [s5]

here are the modified files:
=============file a.scxml=====================================
<?xml version="1.0"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml"
		xmlns:cs="http://commons.apache.org/scxml"
       version="1.0"
       profile="ecmascript"
       initial="s1">

  <!--  trivial 5 second microwave oven example -->
  <!--  see http://commons.apache.org/scxml/guide/datamodel.html for
different way to access the datamodel -->
  <datamodel>
    <data id="cook_time" expr="10"/>
	 <data id="AAA" expr="''"/>
  </datamodel>

  <state id="s1">
    <!-- off state -->
    <transition target="s2"/>
  </state>

  <state id="s2" src="b.scxml#s111">

    <!-- on/pause state -->
	
    <transition event="s2.done" cond="AAA eq 's3'" target="s3"/>
    <transition event="s2.done" cond="AAA eq 's4'" target="s4"/>
    <transition event="s2.done" target="s5"/>
	<onexit>
		<log expr="AAA"/>
	</onexit>
  </state>

    <final id="s3"/>
    <final id="s4"/>
    <final id="s5"/>
</scxml>
=============end of file a.scxml==============================

=============file b.scxml=====================================
<?xml version="1.0" encoding="us-ascii"?>
<scxml version="1.0" xmlns="http://www.w3.org/2005/07/scxml"
xmlns:cs="http://commons.apache.org/scxml" initial="s111">
	<state id="s111">
	<initial><transition target="s11"/></initial>

    <state id="s11">
		<transition target="s12">
				<!--<cs:var name="aaa" expr="'s3'" />-->
				<assign location="AAA" expr="'s3'"/>
		</transition>
    </state>

	<final id="s12">
	</final>
	</state>
</scxml>
=============end of file b.scxml==============================

thanks,
fabrizio.

On Thu, May 6, 2010 at 09:52, Rahul Akolkar <ra...@gmail.com> wrote:
> On Thu, May 6, 2010 at 11:34 AM, Fabrizio Morbini <fm...@gmail.com> wrote:
>> Hi, i'm experimenting with the src attribute to reuse fsm. I'm having
>> some trouble with returning a value from an included fsm to the
>> calling state.
>>
>> I'm using this description at
>> http://shale.apache.org/shale-dialog-scxml/index.html, in particular
>> the section about subdialogs from which it seems possible to return a
>> value from an included scxml fsm.
>> However i have been unable to do so. I've tried several variants but
>> none with the expected outcome.
> <snip/>
>
> The Commons SCXML v0.9 release does not use a flat / global datamodel
> by default, therefore the value would need to be copied up to a
> datamodel with a superior position in the states topology (such as
> document root to be available across any other state). I will outline
> this approach using your example below.
>
> Alternatively, provide the SCXMLExecutor with a custom Evaluator
> implementation that returns the same context (the root context) on
> every Evaluator#newContext() call to obtain a flat datamodel. If you
> do this, there would be no changes required to the example below.
>
> Now, for the first approach with the default cascading datamodel, see below:
>
>
>> Here is the current variant:
>>
>> =============file a.scxml=====================================
>> <?xml version="1.0"?>
>> <scxml xmlns="http://www.w3.org/2005/07/scxml"
>>                xmlns:cs="http://commons.apache.org/scxml"
>>       version="1.0"
>>       profile="ecmascript"
>>       initial="s1">
>>
>>  <!--  trivial 5 second microwave oven example -->
>>  <!--  see http://commons.apache.org/scxml/guide/datamodel.html for
>> different way to access the datamodel -->
>>  <datamodel>
>>    <data id="cook_time" expr="10"/>
> <snap/>
>
> Define a global 'aaa' variable here, say like so (note different case
> used here, i.e. chose a different name of choice):
>
>     <data id="AAA" />
>
>
>>  </datamodel>
>>
>>  <state id="s1">
>>    <!-- off state -->
>>    <transition target="s2"/>
>>  </state>
>>
>>  <state id="s2" src="b.scxml#s111">
>>
>>    <!-- on/pause state -->
>>
>>    <transition event="s2.done" cond="aaa eq 's3'" target="s3"/>
>>    <transition event="s2.done" cond="aaa eq 's4'" target="s4"/>
>>    <transition event="s2.done" target="s5"/>
>>
>>  </state>
>>
>>    <final id="s3"/>
>>    <final id="s4"/>
>>    <final id="s5"/>
>> </scxml>
>> =============end of file a.scxml==============================
>>
>> =============file b.scxml=====================================
>> <?xml version="1.0" encoding="us-ascii"?>
>> <scxml version="1.0" xmlns="http://www.w3.org/2005/07/scxml"
>> xmlns:cs="http://commons.apache.org/scxml" initial="s111">
>>        <state id="s111">
>>        <initial><transition target="s11"/></initial>
>>        <datamodel><data id="aaa"/></datamodel>
>>
>>    <state id="s11">
>>                <transition target="s12">
>>                                <!--<cs:var name="aaa" expr="'s3'" />-->
>>                                <assign location="aaa" expr="'s3'"/>
> <snip/>
>
> Change the above to point to the variable defined in the parent
> document above like so:
>
>         <assign location="AAA" expr="'s3'"/>
>
> Obviously, this would imply that b.scxml could only be executed when
> included in a.scxml since it references a datamodel variable in
> a.scxml. If that is not desired, the second approach i.e. the flat
> datamodel approach should be used.
>
>
>>                </transition>
>>    </state>
>>
>>        <final id="s12">
>>        </final>
>>        </state>
>> </scxml>
>> =============end of file b.scxml==============================
>>
>> i tried to use also <var> instead of a previously defined variable in
>> the datamodel, without success.
>>
>> the simple way would be to use the donedata in a final state in the
>> included fsm but it doesn't seem that donedata is supported, is this
>> correct?
>>
> <snap/>
>
> Yes, not in v0.9, we will look to add it soon. You could open a JIRA
> issue as a reminder.
>
>
>> given that src is not going to be supported in the next standard, do
>> you have some pointer to examples/doc of how to use xinclude to do
>> what the src is supposed to do?
>>
> <snip/>
>
> Don't have a ready example, but the idea is to pull in as much of the
> document as needs to be reused using XInclude. See XInclude
> specification for more details. It certain cases, the XInclude
> approach requires more work but is favored since its a standard way to
> do includes.
>
> -Rahul
>
>
>> thanks,
>> fabrizio.
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [scxml] templating/src/xinclude and returning a value(through datamodel/donedata)

Posted by Rahul Akolkar <ra...@gmail.com>.
On Thu, May 6, 2010 at 11:34 AM, Fabrizio Morbini <fm...@gmail.com> wrote:
> Hi, i'm experimenting with the src attribute to reuse fsm. I'm having
> some trouble with returning a value from an included fsm to the
> calling state.
>
> I'm using this description at
> http://shale.apache.org/shale-dialog-scxml/index.html, in particular
> the section about subdialogs from which it seems possible to return a
> value from an included scxml fsm.
> However i have been unable to do so. I've tried several variants but
> none with the expected outcome.
<snip/>

The Commons SCXML v0.9 release does not use a flat / global datamodel
by default, therefore the value would need to be copied up to a
datamodel with a superior position in the states topology (such as
document root to be available across any other state). I will outline
this approach using your example below.

Alternatively, provide the SCXMLExecutor with a custom Evaluator
implementation that returns the same context (the root context) on
every Evaluator#newContext() call to obtain a flat datamodel. If you
do this, there would be no changes required to the example below.

Now, for the first approach with the default cascading datamodel, see below:


> Here is the current variant:
>
> =============file a.scxml=====================================
> <?xml version="1.0"?>
> <scxml xmlns="http://www.w3.org/2005/07/scxml"
>                xmlns:cs="http://commons.apache.org/scxml"
>       version="1.0"
>       profile="ecmascript"
>       initial="s1">
>
>  <!--  trivial 5 second microwave oven example -->
>  <!--  see http://commons.apache.org/scxml/guide/datamodel.html for
> different way to access the datamodel -->
>  <datamodel>
>    <data id="cook_time" expr="10"/>
<snap/>

Define a global 'aaa' variable here, say like so (note different case
used here, i.e. chose a different name of choice):

    <data id="AAA" />


>  </datamodel>
>
>  <state id="s1">
>    <!-- off state -->
>    <transition target="s2"/>
>  </state>
>
>  <state id="s2" src="b.scxml#s111">
>
>    <!-- on/pause state -->
>
>    <transition event="s2.done" cond="aaa eq 's3'" target="s3"/>
>    <transition event="s2.done" cond="aaa eq 's4'" target="s4"/>
>    <transition event="s2.done" target="s5"/>
>
>  </state>
>
>    <final id="s3"/>
>    <final id="s4"/>
>    <final id="s5"/>
> </scxml>
> =============end of file a.scxml==============================
>
> =============file b.scxml=====================================
> <?xml version="1.0" encoding="us-ascii"?>
> <scxml version="1.0" xmlns="http://www.w3.org/2005/07/scxml"
> xmlns:cs="http://commons.apache.org/scxml" initial="s111">
>        <state id="s111">
>        <initial><transition target="s11"/></initial>
>        <datamodel><data id="aaa"/></datamodel>
>
>    <state id="s11">
>                <transition target="s12">
>                                <!--<cs:var name="aaa" expr="'s3'" />-->
>                                <assign location="aaa" expr="'s3'"/>
<snip/>

Change the above to point to the variable defined in the parent
document above like so:

        <assign location="AAA" expr="'s3'"/>

Obviously, this would imply that b.scxml could only be executed when
included in a.scxml since it references a datamodel variable in
a.scxml. If that is not desired, the second approach i.e. the flat
datamodel approach should be used.


>                </transition>
>    </state>
>
>        <final id="s12">
>        </final>
>        </state>
> </scxml>
> =============end of file b.scxml==============================
>
> i tried to use also <var> instead of a previously defined variable in
> the datamodel, without success.
>
> the simple way would be to use the donedata in a final state in the
> included fsm but it doesn't seem that donedata is supported, is this
> correct?
>
<snap/>

Yes, not in v0.9, we will look to add it soon. You could open a JIRA
issue as a reminder.


> given that src is not going to be supported in the next standard, do
> you have some pointer to examples/doc of how to use xinclude to do
> what the src is supposed to do?
>
<snip/>

Don't have a ready example, but the idea is to pull in as much of the
document as needs to be reused using XInclude. See XInclude
specification for more details. It certain cases, the XInclude
approach requires more work but is favored since its a standard way to
do includes.

-Rahul


> thanks,
> fabrizio.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org