[SCXML] Retrieving a (wrapped) NodeSet for an XPath / user defined XPath functions

18 messages Options
Embed this post
Permalink
Jaroslav Pullmann-3

[SCXML] Retrieving a (wrapped) NodeSet for an XPath / user defined XPath functions

Reply Threaded More More options
Print post
Permalink

  Dear Rahul, dear all,

   the result value of an XPath-selection is limited to an XPathConstants.NODE
  as of XPathEvaluator#evalLocation(Context, String). Having a root element is
  reasonable for assignments etc. but I'd need to select a NodeSet based on the
  XPath predicates first (and then wrap it evt. into a result element).

  My use case resembles the form interpretation algorithm (FIA) of VXML: the
  <datamodel> of a state is updated continually by the payload of arriving events
  (inputs). There is an UI (form) which reflects the current datamodel and on each
  change the remaining "empty" <data> items should be selected and presented for
  completion:

<state id="collectInput">
        <datamodel>
                <data id="statedata">...</data>
                <data id="empty"><my:empty xmlns:my="urn:myns"/></data>
        </datamodel>
                       
               
        <transition event="submit">

                <!-- store input -->
                <assign expr="$_eventdata/data" location="$statedata/dataitem[@id = $_eventdata/data/@id]"/>

                <!-- test for remaining empty fields, wrap resulting NodeSet into "my:empty" element  -->
                <assign expr="my:filter($statedata/item[. = ''],'my:empty')" location="$empty" />

                <myfn:updateGUI/>

        </transition>
       
        <transition cond="count($empty/my:empty) = 0" target="nextInputState" />

  </state>


  Although the XPathEvaluator accpets XPathFunctions as constructor arguments,
  there are no public accessors to the namespace and variable contexts. Could you
  please provide an exmaple how to accomplish access to a data NodeSet using an
  XPathFunction or an other way ?

   Many thanks !
     Jaro











--
Jaroslav Pullmann
Web Compliance Center - Fraunhofer FIT
Schloss Birlinghoven, D-53757 Sankt Augustin, Germany
Phone: +49-2241-142623    Fax: +49-2241-142065

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Rahul Akolkar

Re: [SCXML] Retrieving a (wrapped) NodeSet for an XPath / user defined XPath functions

Reply Threaded More More options
Print post
Permalink
On Tue, Oct 20, 2009 at 10:42 AM, Jaroslav Pullmann
<[hidden email]> wrote:

>
>  Dear Rahul, dear all,
>
>  the result value of an XPath-selection is limited to an XPathConstants.NODE
>  as of XPathEvaluator#evalLocation(Context, String). Having a root element
> is
>  reasonable for assignments etc. but I'd need to select a NodeSet based on
> the
>  XPath predicates first (and then wrap it evt. into a result element).
>
<snip/>

Right, the XPathEvaluator only supports types that it needs to fulfill
its contracts (generic expression, boolean or node result). Executing
an operation or task with arbitrary semantics requires either
extension functions or custom actions.


>  My use case resembles the form interpretation algorithm (FIA) of VXML: the
>  <datamodel> of a state is updated continually by the payload of arriving
> events
>  (inputs). There is an UI (form) which reflects the current datamodel and on
> each
>  change the remaining "empty" <data> items should be selected and presented
> for
>  completion:
>
> <state id="collectInput">
>        <datamodel>
>                <data id="statedata">...</data>
>                <data id="empty"><my:empty xmlns:my="urn:myns"/></data>
>        </datamodel>
>
>
>        <transition event="submit">
>
>                <!-- store input -->
>                <assign expr="$_eventdata/data"
> location="$statedata/dataitem[@id = $_eventdata/data/@id]"/>
>
>                <!-- test for remaining empty fields, wrap resulting NodeSet
> into "my:empty" element  -->
>                <assign expr="my:filter($statedata/item[. = ''],'my:empty')"
> location="$empty" />
>
>                <myfn:updateGUI/>
>
>        </transition>
>
>        <transition cond="count($empty/my:empty) = 0" target="nextInputState"
> />
>
>  </state>
>
>
>  Although the XPathEvaluator accpets XPathFunctions as constructor
> arguments,
>  there are no public accessors to the namespace and variable contexts. Could
> you
>  please provide an exmaple how to accomplish access to a data NodeSet using
> an
>  XPathFunction or an other way ?
>
<snap/>

You're correct that the namespace and variable contexts are not
trivially exposed to the functions and that is also sort of a thumb
rule on whether to use a function or an action.

I'd recommend using a custom action that captures these specific
semantics aiding behavior akin to the FIA, rather than having it
happen as a side-effect of a function invocation in an assignment
expression. IOW, if you have an action to the effect of the following
that has the behavior above:

  <myfn:assign nodeset="$statedata/item[. = '']" wrapper="my:empty"
location="$empty"/>

it (a) offers you access to the namespace and variable contexts, and
(b) models this separately from <assign> since it is indeed a
composite operation.

-Rahul


>  Many thanks !
>    Jaro
>
>
>
> --
> Jaroslav Pullmann
> Web Compliance Center - Fraunhofer FIT
> Schloss Birlinghoven, D-53757 Sankt Augustin, Germany
> Phone: +49-2241-142623    Fax: +49-2241-142065
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Jaroslav Pullmann-3

[SCXML] XPathEvaluator / Error accessing complex event payload

Reply Threaded More More options
Print post
Permalink
  Hello Rahul,
  although not yet officially released I like using the J6 branch
  (commons-scxml-1.0-SNAPSHOT.jar) because of its XPath support.
  Recently I experience problems when accessing the complex event
  payload (Node: <payload><data><status>started</status></data></payload>,
  plain string payload is o.k.)

  This works fine with JexlEvaluator:

        <transition event="statuschange">
                <log label="Status changed to" expr="Data(_eventdata.payload,'/data/status')"/>
        </transition>

  but is broken with XPathEvaluator:

        <transition event="statuschange">
                <log label="Message" expr="$_eventdata/data/status"/>
        </transition>


javax.xml.transform.TransformerException: org.apache.xpath.objects.XObject incompatible with
org.apache.xpath.objects.XNodeSet
        at org.apache.xpath.XPath.execute(Unknown Source)
        at org.apache.xpath.jaxp.XPathExpressionImpl.evaluate(Unknown Source)
        at org.apache.xpath.jaxp.XPathImpl.evaluate(Unknown Source)
        at org.apache.commons.scxml.env.xpath.XPathEvaluator.eval(XPathEvaluator.java:90)
        at org.apache.commons.scxml.model.Log.execute(Log.java:107)
        at org.apache.commons.scxml.semantics.SCXMLSemanticsImpl.executeActions(SCXMLSemanticsImpl.java:223)
        at org.apache.commons.scxml.SCXMLExecutor.triggerEvents(SCXMLExecutor.java:131)
       
Caused by: java.lang.ClassCastException: org.apache.xpath.objects.XObject incompatible with
org.apache.xpath.objects.XNodeSet
        at org.apache.xpath.axes.FilterExprIteratorSimple.executeFilterExpr(Unknown Source)
        at org.apache.xpath.axes.FilterExprWalker.setRoot(Unknown Source)
        at org.apache.xpath.axes.WalkingIterator.setRoot(Unknown Source)
        at org.apache.xpath.axes.NodeSequence.setRoot(Unknown Source)
        at org.apache.xpath.axes.LocPathIterator.execute(Unknown Source)
        ... 13 more


        Is this may be due to an incorrect variable naming or whichever user error ?

     Many thanks for your help!
       Jaro


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Rahul Akolkar

Re: [SCXML] XPathEvaluator / Error accessing complex event payload

Reply Threaded More More options
Print post
Permalink
On Sun, Oct 25, 2009 at 11:47 AM, Jaroslav Pullmann
<[hidden email]> wrote:

>  Hello Rahul,
>  although not yet officially released I like using the J6 branch
>  (commons-scxml-1.0-SNAPSHOT.jar) because of its XPath support.
>  Recently I experience problems when accessing the complex event
>  payload (Node: <payload><data><status>started</status></data></payload>,
>  plain string payload is o.k.)
>
>  This works fine with JexlEvaluator:
>
>        <transition event="statuschange">
>                <log label="Status changed to"
> expr="Data(_eventdata.payload,'/data/status')"/>
>        </transition>
>
>  but is broken with XPathEvaluator:
>
>        <transition event="statuschange">
>                <log label="Message" expr="$_eventdata/data/status"/>
>        </transition>
>
<snip/>

The two evaluators handle XPath processing differently, so in order to
track down the error below, please say more as to how you obtained the
Node that became the event payload. For example, if the
DocumentBuilder API is used to parse the above XML, I'd expect it to
work in either cases. I would, however, expect the expression when
using the XPath evaluator in this case to be either
"$_eventdata/payload/data/status" or "$_eventdata//data/status" (note
two /s before data). As an aside, for good measure, specifying an
xmlns on payloads is also recommended practice i.e. <payload
xmlns="">...</payload>.

Also say something about the environment and how we're seeing xalan
classes in the traces that aren't repackaged. The J6 branch requires
JDK 1.6 where, for example, I'd expect to see something like
com.sun.org.apache.xpath.internal.XPath as against
org.apache.xpath.XPath in the traces.

In order for us to reproduce this, if you can produce a small JUnit
test case in the Commons SCXML test suite (see existing ones in
src/test/java/...oacse.../xpath) that produces the trace below, that
can also help.

-Rahul


>
> javax.xml.transform.TransformerException: org.apache.xpath.objects.XObject
> incompatible with org.apache.xpath.objects.XNodeSet
>        at org.apache.xpath.XPath.execute(Unknown Source)
>        at org.apache.xpath.jaxp.XPathExpressionImpl.evaluate(Unknown Source)
>        at org.apache.xpath.jaxp.XPathImpl.evaluate(Unknown Source)
>        at
> org.apache.commons.scxml.env.xpath.XPathEvaluator.eval(XPathEvaluator.java:90)
>        at org.apache.commons.scxml.model.Log.execute(Log.java:107)
>        at
> org.apache.commons.scxml.semantics.SCXMLSemanticsImpl.executeActions(SCXMLSemanticsImpl.java:223)
>        at
> org.apache.commons.scxml.SCXMLExecutor.triggerEvents(SCXMLExecutor.java:131)
>
> Caused by: java.lang.ClassCastException: org.apache.xpath.objects.XObject
> incompatible with org.apache.xpath.objects.XNodeSet
>        at
> org.apache.xpath.axes.FilterExprIteratorSimple.executeFilterExpr(Unknown
> Source)
>        at org.apache.xpath.axes.FilterExprWalker.setRoot(Unknown Source)
>        at org.apache.xpath.axes.WalkingIterator.setRoot(Unknown Source)
>        at org.apache.xpath.axes.NodeSequence.setRoot(Unknown Source)
>        at org.apache.xpath.axes.LocPathIterator.execute(Unknown Source)
>        ... 13 more
>
>
>        Is this may be due to an incorrect variable naming or whichever user
> error ?
>
>    Many thanks for your help!
>      Jaro
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Jaroslav Pullmann-3

Re: [SCXML] XPathEvaluator / Error accessing complex event payload

Reply Threaded More More options
Print post
Permalink


  Hello Rahul,
   sorry for the late response, I've been out of office last week.
  I looked at the code once again and found the error cause. The payload
  was in deed wrapped into a bean with a dedicated accessor method
  Node getPayload(), instead of passing the node directly. This worked
  only with the Jexl-evaluator..

  Please find attached the extended test suite for XPath. This may
  be of interest for other users in a comparative documentation of
  the XPath-based access to event payload and data models .
    Best regards
     Jaro




Rahul Akolkar wrote:

> On Sun, Oct 25, 2009 at 11:47 AM, Jaroslav Pullmann
> <[hidden email]> wrote:
>>  Hello Rahul,
>>  although not yet officially released I like using the J6 branch
>>  (commons-scxml-1.0-SNAPSHOT.jar) because of its XPath support.
>>  Recently I experience problems when accessing the complex event
>>  payload (Node: <payload><data><status>started</status></data></payload>,
>>  plain string payload is o.k.)
>>
>>  This works fine with JexlEvaluator:
>>
>>        <transition event="statuschange">
>>                <log label="Status changed to"
>> expr="Data(_eventdata.payload,'/data/status')"/>
>>        </transition>
>>
>>  but is broken with XPathEvaluator:
>>
>>        <transition event="statuschange">
>>                <log label="Message" expr="$_eventdata/data/status"/>
>>        </transition>
>>
> <snip/>
>
> The two evaluators handle XPath processing differently, so in order to
> track down the error below, please say more as to how you obtained the
> Node that became the event payload. For example, if the
> DocumentBuilder API is used to parse the above XML, I'd expect it to
> work in either cases. I would, however, expect the expression when
> using the XPath evaluator in this case to be either
> "$_eventdata/payload/data/status" or "$_eventdata//data/status" (note
> two /s before data). As an aside, for good measure, specifying an
> xmlns on payloads is also recommended practice i.e. <payload
> xmlns="">...</payload>.
>
> Also say something about the environment and how we're seeing xalan
> classes in the traces that aren't repackaged. The J6 branch requires
> JDK 1.6 where, for example, I'd expect to see something like
> com.sun.org.apache.xpath.internal.XPath as against
> org.apache.xpath.XPath in the traces.
>
> In order for us to reproduce this, if you can produce a small JUnit
> test case in the Commons SCXML test suite (see existing ones in
> src/test/java/...oacse.../xpath) that produces the trace below, that
> can also help.
>
> -Rahul
>
>
>> javax.xml.transform.TransformerException: org.apache.xpath.objects.XObject
>> incompatible with org.apache.xpath.objects.XNodeSet
>>        at org.apache.xpath.XPath.execute(Unknown Source)
>>        at org.apache.xpath.jaxp.XPathExpressionImpl.evaluate(Unknown Source)
>>        at org.apache.xpath.jaxp.XPathImpl.evaluate(Unknown Source)
>>        at
>> org.apache.commons.scxml.env.xpath.XPathEvaluator.eval(XPathEvaluator.java:90)
>>        at org.apache.commons.scxml.model.Log.execute(Log.java:107)
>>        at
>> org.apache.commons.scxml.semantics.SCXMLSemanticsImpl.executeActions(SCXMLSemanticsImpl.java:223)
>>        at
>> org.apache.commons.scxml.SCXMLExecutor.triggerEvents(SCXMLExecutor.java:131)
>>
>> Caused by: java.lang.ClassCastException: org.apache.xpath.objects.XObject
>> incompatible with org.apache.xpath.objects.XNodeSet
>>        at
>> org.apache.xpath.axes.FilterExprIteratorSimple.executeFilterExpr(Unknown
>> Source)
>>        at org.apache.xpath.axes.FilterExprWalker.setRoot(Unknown Source)
>>        at org.apache.xpath.axes.WalkingIterator.setRoot(Unknown Source)
>>        at org.apache.xpath.axes.NodeSequence.setRoot(Unknown Source)
>>        at org.apache.xpath.axes.LocPathIterator.execute(Unknown Source)
>>        ... 13 more
>>
>>
>>        Is this may be due to an incorrect variable naming or whichever user
>> error ?
>>
>>    Many thanks for your help!
>>      Jaro
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

--
Jaroslav Pullmann
Web Compliance Center - Fraunhofer FIT
Schloss Birlinghoven, D-53757 Sankt Augustin, Germany
Phone: +49-2241-142623    Fax: +49-2241-142065



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

XPathTestSuite.zip (8K) Download Attachment
Rahul Akolkar

Re: [SCXML] XPathEvaluator / Error accessing complex event payload

Reply Threaded More More options
Print post
Permalink
On Tue, Nov 3, 2009 at 6:52 AM, Jaroslav Pullmann
<[hidden email]> wrote:
>
>
>  Hello Rahul,
>  sorry for the late response, I've been out of office last week.
>  I looked at the code once again and found the error cause. The payload
>  was in deed wrapped into a bean with a dedicated accessor method
>  Node getPayload(), instead of passing the node directly. This worked
>  only with the Jexl-evaluator..
>
<snip/>

Cool, makes sense.

-Rahul


>  Please find attached the extended test suite for XPath. This may
>  be of interest for other users in a comparative documentation of
>  the XPath-based access to event payload and data models        .
>   Best regards
>    Jaro
>
>
>
>
> Rahul Akolkar wrote:
>>
>> On Sun, Oct 25, 2009 at 11:47 AM, Jaroslav Pullmann
>> <[hidden email]> wrote:
>>>
>>>  Hello Rahul,
>>>  although not yet officially released I like using the J6 branch
>>>  (commons-scxml-1.0-SNAPSHOT.jar) because of its XPath support.
>>>  Recently I experience problems when accessing the complex event
>>>  payload (Node: <payload><data><status>started</status></data></payload>,
>>>  plain string payload is o.k.)
>>>
>>>  This works fine with JexlEvaluator:
>>>
>>>       <transition event="statuschange">
>>>               <log label="Status changed to"
>>> expr="Data(_eventdata.payload,'/data/status')"/>
>>>       </transition>
>>>
>>>  but is broken with XPathEvaluator:
>>>
>>>       <transition event="statuschange">
>>>               <log label="Message" expr="$_eventdata/data/status"/>
>>>       </transition>
>>>
>> <snip/>
>>
>> The two evaluators handle XPath processing differently, so in order to
>> track down the error below, please say more as to how you obtained the
>> Node that became the event payload. For example, if the
>> DocumentBuilder API is used to parse the above XML, I'd expect it to
>> work in either cases. I would, however, expect the expression when
>> using the XPath evaluator in this case to be either
>> "$_eventdata/payload/data/status" or "$_eventdata//data/status" (note
>> two /s before data). As an aside, for good measure, specifying an
>> xmlns on payloads is also recommended practice i.e. <payload
>> xmlns="">...</payload>.
>>
>> Also say something about the environment and how we're seeing xalan
>> classes in the traces that aren't repackaged. The J6 branch requires
>> JDK 1.6 where, for example, I'd expect to see something like
>> com.sun.org.apache.xpath.internal.XPath as against
>> org.apache.xpath.XPath in the traces.
>>
>> In order for us to reproduce this, if you can produce a small JUnit
>> test case in the Commons SCXML test suite (see existing ones in
>> src/test/java/...oacse.../xpath) that produces the trace below, that
>> can also help.
>>
>> -Rahul
>>
>>
>>> javax.xml.transform.TransformerException:
>>> org.apache.xpath.objects.XObject
>>> incompatible with org.apache.xpath.objects.XNodeSet
>>>       at org.apache.xpath.XPath.execute(Unknown Source)
>>>       at org.apache.xpath.jaxp.XPathExpressionImpl.evaluate(Unknown
>>> Source)
>>>       at org.apache.xpath.jaxp.XPathImpl.evaluate(Unknown Source)
>>>       at
>>>
>>> org.apache.commons.scxml.env.xpath.XPathEvaluator.eval(XPathEvaluator.java:90)
>>>       at org.apache.commons.scxml.model.Log.execute(Log.java:107)
>>>       at
>>>
>>> org.apache.commons.scxml.semantics.SCXMLSemanticsImpl.executeActions(SCXMLSemanticsImpl.java:223)
>>>       at
>>>
>>> org.apache.commons.scxml.SCXMLExecutor.triggerEvents(SCXMLExecutor.java:131)
>>>
>>> Caused by: java.lang.ClassCastException: org.apache.xpath.objects.XObject
>>> incompatible with org.apache.xpath.objects.XNodeSet
>>>       at
>>> org.apache.xpath.axes.FilterExprIteratorSimple.executeFilterExpr(Unknown
>>> Source)
>>>       at org.apache.xpath.axes.FilterExprWalker.setRoot(Unknown Source)
>>>       at org.apache.xpath.axes.WalkingIterator.setRoot(Unknown Source)
>>>       at org.apache.xpath.axes.NodeSequence.setRoot(Unknown Source)
>>>       at org.apache.xpath.axes.LocPathIterator.execute(Unknown Source)
>>>       ... 13 more
>>>
>>>
>>>       Is this may be due to an incorrect variable naming or whichever
>>> user
>>> error ?
>>>
>>>   Many thanks for your help!
>>>     Jaro
>>>
>>>
>
>
> --
> Jaroslav Pullmann
> Web Compliance Center - Fraunhofer FIT
> Schloss Birlinghoven, D-53757 Sankt Augustin, Germany
> Phone: +49-2241-142623    Fax: +49-2241-142065
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Jaroslav Pullmann-3

Re: [SCXML] Retrieving a (wrapped) NodeSet for an XPath / user defined XPath functions

Reply Threaded More More options
Print post
Permalink
In reply to this post by Rahul Akolkar


  Dear Rahul,
   thank you for responding. Essentially the use case is simply
   a selection of a NodeSet instead of a Node and this seeems
   to be what the spec (WD May 2008) guarantees:

   9.3.3.1 Location Expressions:
  "XPath 2.0 expressions are used to select a node-set
   from the data model by providing a binding expression..."

   9.3.3.2 Value Expressions:
   "If the result of the value expression is a node-set,
   a deep copy of the subtree rooted at each node is made."

   Given this I wonder why the signature of the method

     Node   Evaluator#evalLocation(Context ctx, String expr)

   is limited to delivering (the first result) XPathConstants.NODE ?

   This single node seems to provides just a conventient container for
   copying the child nodes in Assign#execute() and be passed as an Invoker
   argument. Could this restrictive contract change in future releases ?

     Many thanks
      Jaro
       

       


Rahul Akolkar wrote:

> On Tue, Oct 20, 2009 at 10:42 AM, Jaroslav Pullmann
> <[hidden email]> wrote:
>>  Dear Rahul, dear all,
>>
>>  the result value of an XPath-selection is limited to an XPathConstants.NODE
>>  as of XPathEvaluator#evalLocation(Context, String). Having a root element
>> is
>>  reasonable for assignments etc. but I'd need to select a NodeSet based on
>> the
>>  XPath predicates first (and then wrap it evt. into a result element).
>>
> <snip/>
>
> Right, the XPathEvaluator only supports types that it needs to fulfill
> its contracts (generic expression, boolean or node result). Executing
> an operation or task with arbitrary semantics requires either
> extension functions or custom actions.
>
>
>>  My use case resembles the form interpretation algorithm (FIA) of VXML: the
>>  <datamodel> of a state is updated continually by the payload of arriving
>> events
>>  (inputs). There is an UI (form) which reflects the current datamodel and on
>> each
>>  change the remaining "empty" <data> items should be selected and presented
>> for
>>  completion:
>>
>> <state id="collectInput">
>>        <datamodel>
>>                <data id="statedata">...</data>
>>                <data id="empty"><my:empty xmlns:my="urn:myns"/></data>
>>        </datamodel>
>>
>>
>>        <transition event="submit">
>>
>>                <!-- store input -->
>>                <assign expr="$_eventdata/data"
>> location="$statedata/dataitem[@id = $_eventdata/data/@id]"/>
>>
>>                <!-- test for remaining empty fields, wrap resulting NodeSet
>> into "my:empty" element  -->
>>                <assign expr="my:filter($statedata/item[. = ''],'my:empty')"
>> location="$empty" />
>>
>>                <myfn:updateGUI/>
>>
>>        </transition>
>>
>>        <transition cond="count($empty/my:empty) = 0" target="nextInputState"
>> />
>>
>>  </state>
>>
>>
>>  Although the XPathEvaluator accpets XPathFunctions as constructor
>> arguments,
>>  there are no public accessors to the namespace and variable contexts. Could
>> you
>>  please provide an exmaple how to accomplish access to a data NodeSet using
>> an
>>  XPathFunction or an other way ?
>>
> <snap/>
>
> You're correct that the namespace and variable contexts are not
> trivially exposed to the functions and that is also sort of a thumb
> rule on whether to use a function or an action.
>
> I'd recommend using a custom action that captures these specific
> semantics aiding behavior akin to the FIA, rather than having it
> happen as a side-effect of a function invocation in an assignment
> expression. IOW, if you have an action to the effect of the following
> that has the behavior above:
>
>   <myfn:assign nodeset="$statedata/item[. = '']" wrapper="my:empty"
> location="$empty"/>
>
> it (a) offers you access to the namespace and variable contexts, and
> (b) models this separately from <assign> since it is indeed a
> composite operation.
>
> -Rahul
>
>
>>  Many thanks !
>>    Jaro
>>
>>
>>
>> --
>> Jaroslav Pullmann
>> Web Compliance Center - Fraunhofer FIT
>> Schloss Birlinghoven, D-53757 Sankt Augustin, Germany
>> Phone: +49-2241-142623    Fax: +49-2241-142065
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


--
Jaroslav Pullmann
Web Compliance Center - Fraunhofer FIT
Schloss Birlinghoven, D-53757 Sankt Augustin, Germany
Phone: +49-2241-142623    Fax: +49-2241-142065

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Rahul Akolkar

Re: [SCXML] Retrieving a (wrapped) NodeSet for an XPath / user defined XPath functions

Reply Threaded More More options
Print post
Permalink
On Thu, Oct 22, 2009 at 3:00 AM, Jaroslav Pullmann
<[hidden email]> wrote:

>
>
>  Dear Rahul,
>  thank you for responding. Essentially the use case is simply
>  a selection of a NodeSet instead of a Node and this seeems
>  to be what the spec (WD May 2008) guarantees:
>
>  9.3.3.1 Location Expressions:
>  "XPath 2.0 expressions are used to select a node-set
>  from the data model by providing a binding expression..."
>
<snip/>

A location expression should identify a unique location in the
datamodel so IMO that needs to change -- I'll bring it up with the WG.
 Thanks for pointing it out.


>  9.3.3.2 Value Expressions:
>  "If the result of the value expression is a node-set,
>  a deep copy of the subtree rooted at each node is made."
>
<snap/>

Value expressions can return nodesets.


>  Given this I wonder why the signature of the method
>
>    Node   Evaluator#evalLocation(Context ctx, String expr)
>
>  is limited to delivering (the first result) XPathConstants.NODE ?
>
>  This single node seems to provides just a conventient container for
>  copying the child nodes in Assign#execute() and be passed as an Invoker
>  argument. Could this restrictive contract change in future releases ?
>
<snip/>

See comment above WRT location expressions. Whether evalLocation()
will change depends on the outcome with the WG, once I get a chance to
check there.

-Rahul


>    Many thanks
>     Jaro
>
>
>
>
>
> Rahul Akolkar wrote:
>>
>> On Tue, Oct 20, 2009 at 10:42 AM, Jaroslav Pullmann
>> <[hidden email]> wrote:
>>>
>>>  Dear Rahul, dear all,
>>>
>>>  the result value of an XPath-selection is limited to an
>>> XPathConstants.NODE
>>>  as of XPathEvaluator#evalLocation(Context, String). Having a root
>>> element
>>> is
>>>  reasonable for assignments etc. but I'd need to select a NodeSet based
>>> on
>>> the
>>>  XPath predicates first (and then wrap it evt. into a result element).
>>>
>> <snip/>
>>
>> Right, the XPathEvaluator only supports types that it needs to fulfill
>> its contracts (generic expression, boolean or node result). Executing
>> an operation or task with arbitrary semantics requires either
>> extension functions or custom actions.
>>
>>
>>>  My use case resembles the form interpretation algorithm (FIA) of VXML:
>>> the
>>>  <datamodel> of a state is updated continually by the payload of arriving
>>> events
>>>  (inputs). There is an UI (form) which reflects the current datamodel and
>>> on
>>> each
>>>  change the remaining "empty" <data> items should be selected and
>>> presented
>>> for
>>>  completion:
>>>
>>> <state id="collectInput">
>>>       <datamodel>
>>>               <data id="statedata">...</data>
>>>               <data id="empty"><my:empty xmlns:my="urn:myns"/></data>
>>>       </datamodel>
>>>
>>>
>>>       <transition event="submit">
>>>
>>>               <!-- store input -->
>>>               <assign expr="$_eventdata/data"
>>> location="$statedata/dataitem[@id = $_eventdata/data/@id]"/>
>>>
>>>               <!-- test for remaining empty fields, wrap resulting
>>> NodeSet
>>> into "my:empty" element  -->
>>>               <assign expr="my:filter($statedata/item[. =
>>> ''],'my:empty')"
>>> location="$empty" />
>>>
>>>               <myfn:updateGUI/>
>>>
>>>       </transition>
>>>
>>>       <transition cond="count($empty/my:empty) = 0"
>>> target="nextInputState"
>>> />
>>>
>>>  </state>
>>>
>>>
>>>  Although the XPathEvaluator accpets XPathFunctions as constructor
>>> arguments,
>>>  there are no public accessors to the namespace and variable contexts.
>>> Could
>>> you
>>>  please provide an exmaple how to accomplish access to a data NodeSet
>>> using
>>> an
>>>  XPathFunction or an other way ?
>>>
>> <snap/>
>>
>> You're correct that the namespace and variable contexts are not
>> trivially exposed to the functions and that is also sort of a thumb
>> rule on whether to use a function or an action.
>>
>> I'd recommend using a custom action that captures these specific
>> semantics aiding behavior akin to the FIA, rather than having it
>> happen as a side-effect of a function invocation in an assignment
>> expression. IOW, if you have an action to the effect of the following
>> that has the behavior above:
>>
>>  <myfn:assign nodeset="$statedata/item[. = '']" wrapper="my:empty"
>> location="$empty"/>
>>
>> it (a) offers you access to the namespace and variable contexts, and
>> (b) models this separately from <assign> since it is indeed a
>> composite operation.
>>
>> -Rahul
>>
>>
>>>  Many thanks !
>>>   Jaro
>>>
>>>
>>>
>>> --
>>> Jaroslav Pullmann
>>> Web Compliance Center - Fraunhofer FIT
>>> Schloss Birlinghoven, D-53757 Sankt Augustin, Germany
>>> Phone: +49-2241-142623    Fax: +49-2241-142065
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
>
> --
> Jaroslav Pullmann
> Web Compliance Center - Fraunhofer FIT
> Schloss Birlinghoven, D-53757 Sankt Augustin, Germany
> Phone: +49-2241-142623    Fax: +49-2241-142065
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Renaud, Martin

[SCXML] Eclipse plugin available ?

Reply Threaded More More options
Print post
Permalink
Hi Rahul,

We've managed to use scxml very successfully in our application. Thanks
a lot for the framework!

I have an "after the fact" question: on the main scxml page, the is a
picture of what seems to be an eclipse plugin that can transform a state
diagram to an .scxml file and vice-versa. I didn't find such a beast...
doest it really exists and if it does, where can we find it?

Thanks,

Martin





---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Rahul Akolkar

Re: [SCXML] Eclipse plugin available ?

Reply Threaded More More options
Print post
Permalink
On Fri, Oct 23, 2009 at 12:46 PM, Renaud, Martin
<[hidden email]> wrote:
> Hi Rahul,
>
> We've managed to use scxml very successfully in our application. Thanks
> a lot for the framework!
>
<snip/>

Good to know.


> I have an "after the fact" question: on the main scxml page, the is a
> picture of what seems to be an eclipse plugin that can transform a state
> diagram to an .scxml file and vice-versa. I didn't find such a beast...
> doest it really exists and if it does, where can we find it?
>
<snap/>

Its not for vanilla Eclipse, the screenshot is from a plugin available
on alphaWorks [1] for the Rational Software Architect (or Modeler will
do too). The alphaWorks plugin is not actively maintained. Another
approach discussed (you'll find a thread or two in the email archives)
is to use Eclipse MDT UML2 Tools and style the XMI into SCXML -- a
simple stylesheet that anyone can begin building on to something more
usable is here [2].

-Rahul

[1] http://www.alphaworks.ibm.com/tech/scxml
[2] http://svn.apache.org/repos/asf/commons/proper/scxml/branches/J6/extras/


> Thanks,
>
> Martin
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Renaud, Martin

RE: [SCXML] Eclipse plugin available ?

Reply Threaded More More options
Print post
Permalink
Ok, thanks for the information.

-----Original Message-----
From: Rahul Akolkar [mailto:[hidden email]]
Sent: Friday, October 23, 2009 6:32 PM
To: Commons Users List
Subject: Re: [SCXML] Eclipse plugin available ?

On Fri, Oct 23, 2009 at 12:46 PM, Renaud, Martin
<[hidden email]> wrote:
> Hi Rahul,
>
> We've managed to use scxml very successfully in our application.
Thanks
> a lot for the framework!
>
<snip/>

Good to know.


> I have an "after the fact" question: on the main scxml page, the is a
> picture of what seems to be an eclipse plugin that can transform a
state
> diagram to an .scxml file and vice-versa. I didn't find such a
beast...
> doest it really exists and if it does, where can we find it?
>
<snap/>

Its not for vanilla Eclipse, the screenshot is from a plugin available
on alphaWorks [1] for the Rational Software Architect (or Modeler will
do too). The alphaWorks plugin is not actively maintained. Another
approach discussed (you'll find a thread or two in the email archives)
is to use Eclipse MDT UML2 Tools and style the XMI into SCXML -- a
simple stylesheet that anyone can begin building on to something more
usable is here [2].

-Rahul

[1] http://www.alphaworks.ibm.com/tech/scxml
[2]
http://svn.apache.org/repos/asf/commons/proper/scxml/branches/J6/extras/


> Thanks,
>
> Martin
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Cedric NICOLAS

RE: [SCXML] Eclipse plugin available ?

Reply Threaded More More options
Print post
Permalink
In reply to this post by Rahul Akolkar
Rahul (and others),

We are also making big progress using SCXML, as the core tool for our
service (see http://www.villefluide.fr). For your information we are using
SCXML as well on server side (commons Java implementation) and client sides
(mobile phones with Qt SCXML implementation now in standard in Qt 4.6) in
order to have a single representation of our business logic, and SCXML is
fantastic as it allows business logic to be completely non-programmatic and
perfectly adapted to MVC pattern. So we are particularly interested in a UI
Design tool being able to parse and generate back and forth SCXML files from
a graphical representation, without going through the heavy XMI standard.
Apart from the two solutions that you mention (Rational plugins that seems
not to be maintained and light xslt template), is there any project to
provide this somewhere ? We are ready to contribute, as our states machines
is becoming quite complex to maintain on a simple XML editor.

Note that we regret that SCXML specification is quite weak on language
mapping, and we have quite different interaction with language between Java
(server side) and Qt/C++ (client-side). It would be much better to include
in SCXML core W3C spec minimum mandatory mapping features for all languages,
like SM data context management, events triggering, SM internal scripting,
and call backs to native code. But at least states/transitions
representations are the same, and this is essential.

Regards,


> Cédric NICOLAS
>
> CEO Ville Fluide S.A.S.
>
> Siège social : 73 Bd Richelieu, 92500 RUEIL-MALMAISON, FRANCE
>
> Bureaux : 11-13 rue du Colonel Pierre Avia, 75015 PARIS
>
> +33 1 55 92 59 08
>
> [hidden email]

-----Message d'origine-----
De : Rahul Akolkar [mailto:[hidden email]]
Envoyé : samedi 24 octobre 2009 00:32
À : Commons Users List
Objet : Re: [SCXML] Eclipse plugin available ?

On Fri, Oct 23, 2009 at 12:46 PM, Renaud, Martin
<[hidden email]> wrote:
> Hi Rahul,
>
> We've managed to use scxml very successfully in our application. Thanks
> a lot for the framework!
>
<snip/>

Good to know.


> I have an "after the fact" question: on the main scxml page, the is a
> picture of what seems to be an eclipse plugin that can transform a state
> diagram to an .scxml file and vice-versa. I didn't find such a beast...
> doest it really exists and if it does, where can we find it?
>
<snap/>

Its not for vanilla Eclipse, the screenshot is from a plugin available
on alphaWorks [1] for the Rational Software Architect (or Modeler will
do too). The alphaWorks plugin is not actively maintained. Another
approach discussed (you'll find a thread or two in the email archives)
is to use Eclipse MDT UML2 Tools and style the XMI into SCXML -- a
simple stylesheet that anyone can begin building on to something more
usable is here [2].

-Rahul

[1] http://www.alphaworks.ibm.com/tech/scxml
[2] http://svn.apache.org/repos/asf/commons/proper/scxml/branches/J6/extras/


> Thanks,
>
> Martin
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Rahul Akolkar

Re: [SCXML] Eclipse plugin available ?

Reply Threaded More More options
Print post
Permalink
In reply to this post by Rahul Akolkar
On Mon, Oct 26, 2009 at 4:54 PM, Cedric NICOLAS
<[hidden email]> wrote:
> Rahul (and others),
>
> We are also making big progress using SCXML, as the core tool for our
> service (see http://www.villefluide.fr). For your information we are using
> SCXML as well on server side (commons Java implementation) and client sides
<snip/>

Cool.

On that note, if any Commons SCXML users want to be listed in the "Who
is using it?" section at the bottom of the home page (
http://commons.apache.org/scxml/ ) please provide a suitable link with
a sentence on how Commons SCXML is used and we'll add it to that
section.


> (mobile phones with Qt SCXML implementation now in standard in Qt 4.6) in
> order to have a single representation of our business logic, and SCXML is
> fantastic as it allows business logic to be completely non-programmatic and
> perfectly adapted to MVC pattern. So we are particularly interested in a UI
> Design tool being able to parse and generate back and forth SCXML files from
> a graphical representation, without going through the heavy XMI standard.
> Apart from the two solutions that you mention (Rational plugins that seems
> not to be maintained and light xslt template), is there any project to
> provide this somewhere ? We are ready to contribute, as our states machines
> is becoming quite complex to maintain on a simple XML editor.
>
<snap/>

It is the need of the hour. I'm not aware of any other open source
solution. Perhaps those with interest in the community can get
something started. I'd be happy to help, but don't have time to
initiate such an effort right now.


> Note that we regret that SCXML specification is quite weak on language
> mapping, and we have quite different interaction with language between Java
> (server side) and Qt/C++ (client-side). It would be much better to include
> in SCXML core W3C spec minimum mandatory mapping features for all languages,
> like SM data context management, events triggering, SM internal scripting,
> and call backs to native code.
<snip/>

True, we simply haven't reached that point yet. I can envision some
IDL definitions that will make the APIs seem familiar across
implementations, but I think that will take a while longer (there are
issues to discuss about the existing bits first).


> But at least states/transitions
> representations are the same, and this is essential.
>
<snap/>

Yup, one step at a time :-)

-Rahul



> Regards,
>
>
>> Cédric NICOLAS
>>
>> CEO Ville Fluide S.A.S.
>>
>> Siège social : 73 Bd Richelieu, 92500 RUEIL-MALMAISON, FRANCE
>>
>> Bureaux : 11-13 rue du Colonel Pierre Avia, 75015 PARIS
>>
>> +33 1 55 92 59 08
>>
>> [hidden email]
>
> -----Message d'origine-----
> De : Rahul Akolkar [mailto:[hidden email]]
> Envoyé : samedi 24 octobre 2009 00:32
> À : Commons Users List
> Objet : Re: [SCXML] Eclipse plugin available ?
>
> On Fri, Oct 23, 2009 at 12:46 PM, Renaud, Martin
> <[hidden email]> wrote:
>> Hi Rahul,
>>
>> We've managed to use scxml very successfully in our application. Thanks
>> a lot for the framework!
>>
> <snip/>
>
> Good to know.
>
>
>> I have an "after the fact" question: on the main scxml page, the is a
>> picture of what seems to be an eclipse plugin that can transform a state
>> diagram to an .scxml file and vice-versa. I didn't find such a beast...
>> doest it really exists and if it does, where can we find it?
>>
> <snap/>
>
> Its not for vanilla Eclipse, the screenshot is from a plugin available
> on alphaWorks [1] for the Rational Software Architect (or Modeler will
> do too). The alphaWorks plugin is not actively maintained. Another
> approach discussed (you'll find a thread or two in the email archives)
> is to use Eclipse MDT UML2 Tools and style the XMI into SCXML -- a
> simple stylesheet that anyone can begin building on to something more
> usable is here [2].
>
> -Rahul
>
> [1] http://www.alphaworks.ibm.com/tech/scxml
> [2] http://svn.apache.org/repos/asf/commons/proper/scxml/branches/J6/extras/
>
>
>> Thanks,
>>
>> Martin
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Cedric NICOLAS

Managing content in an SCXML file

Reply Threaded More More options
Print post
Permalink
Dear Rahul and others,

I want to do a quite simple thing : having a state machine on a server
controlling user interface of mobile clients.
The state machine would have a lot of states and complex stream, and for
some specific states it will embedded a simple markup language content (e.g.
an html subset) that will be delivered to the mobile client which when it
receives it, interpret and display it.

For example the server state machine would have "connect" state that will be
triggered when the mobile is establishing a connection, and would react by
giving to the mobile client the content to be displayed. An simple example
would be :

<state id="connect">
        <content>
                <title> Welcome ! </title>
                <button> text="Click here to continue" action ="send_OK"
</button>
                <button> text="Quit" action ="send_Quit" </button>
</content>
        <transition event="send_OK" target="next_state"/>
        <transition event="send_Quit" target="final_state"/>
</state>

In that case the content in <content> tags will be retrieved by the Java
code on void connect() method, and sent to the device. Server will listen to
device and when receiving a message like send_OK, trigger this to the state
machine.

To summarize I want to emulate a tiny web server hosting some tiny pages
with a state machine.

I've gone through all the documentation of Commons Scxml, and didn't find an
easy way to do this. The possible ways I see are to use a data model, but
using <assign> tags for setting my content seems to be quite heavy to write
and don't know how to assign an XML tree to a data model node, and other
possibility would be to use maybe custom actions, but how to describe in a
simple way my XML like-content ?

Do you have a suggestion to do this in an easy and readable way ?



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

mgainty

RE: Managing content in an SCXML file

Reply Threaded More More options
Print post
Permalink

Cedric

a markup implies SGML..i assume this might be described as XSD or XML Schema Definition?
Can you describe the events this state-machine model would support?
can you describe the content each event would carry and or generate?
Can you describe what would be contained in the header for each Event?
Can you describe what the body would look like for each event?

You might be able to implement a simple listener that listens on fixed host/port and when message is received (EOT is achieved after receiving header and body)
you can hand the body of the message to device

can you confine the size of the message?
if not you might want to implement a packet model to buffer the packets to a known structure
(as in some sort of linked-list)
until body EOT is achieved

sounds like a fun project!
Bon Chance
Martin Gainty
______________________________________________
Note de déni et de confidentialité
 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: [hidden email]
> To: [hidden email]
> Subject: Managing content in an SCXML file
> Date: Tue, 3 Nov 2009 23:23:01 +0100
>
> Dear Rahul and others,
>
> I want to do a quite simple thing : having a state machine on a server
> controlling user interface of mobile clients.
> The state machine would have a lot of states and complex stream, and for
> some specific states it will embedded a simple markup language content (e.g.
> an html subset) that will be delivered to the mobile client which when it
> receives it, interpret and display it.
>
> For example the server state machine would have "connect" state that will be
> triggered when the mobile is establishing a connection, and would react by
> giving to the mobile client the content to be displayed. An simple example
> would be :
>
> <state id="connect">
> <content>
> <title> Welcome ! </title>
> <button> text="Click here to continue" action ="send_OK"
> </button>
> <button> text="Quit" action ="send_Quit" </button>
> </content>
> <transition event="send_OK" target="next_state"/>
> <transition event="send_Quit" target="final_state"/>
> </state>
>
> In that case the content in <content> tags will be retrieved by the Java
> code on void connect() method, and sent to the device. Server will listen to
> device and when receiving a message like send_OK, trigger this to the state
> machine.
>
> To summarize I want to emulate a tiny web server hosting some tiny pages
> with a state machine.
>
> I've gone through all the documentation of Commons Scxml, and didn't find an
> easy way to do this. The possible ways I see are to use a data model, but
> using <assign> tags for setting my content seems to be quite heavy to write
> and don't know how to assign an XML tree to a data model node, and other
> possibility would be to use maybe custom actions, but how to describe in a
> simple way my XML like-content ?
>
> Do you have a suggestion to do this in an easy and readable way ?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
     
_________________________________________________________________
Windows 7: Unclutter your desktop.
http://go.microsoft.com/?linkid=9690331&ocid=PID24727::T:WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen:112009
Cedric NICOLAS

RE: Managing content in an SCXML file

Reply Threaded More More options
Print post
Permalink
Martin,

Thanks for answer. Events for this state machine are quite simple, and I've
already fully implemented the communication layer. Events type being
triggered to the state machine will be :
        - a first connexion from a device,
        - a message from the device
        - an event from a master controller state machine.

The state machine in return can trigger events to :
        - the device that the SM is managing
        - the master controller state machine.

To be a little be more precise, there will be on server side on state
machine instance being created for each new device. Each of these instances
will control the corresponding device state, remotely, if you want. Then
there is a master state machine coordinating all devices children states
machines, as there is no direct communication between devices.

Objective is to have on the mobile device the lightest possible client
software, in order to be able to port easily that software on the different
mobile platforms, and also to have the full control as well of the business
logic but also of the UI on the server side, to be able to upgrade the UI on
the fly. The Scxml file will then fully define the behavior of the device,
but also the UI being displayed. The UI on mobile side is very very simple,
it is much lighter than HTML is. We will have one or two text fields and 3
buttons. It is why our markup language will be very simple as well : a tag
to fill the text field, and a tag to define button text and event.

My only concern here is how to embed easily in an scxml file this 2-tags
markup language for each state. This in order to have in only one state
machine file, as well the full business logic but the UI definition as well.
I don't want to have a separate resource file to handle the UI, in order to
have the scxml file defining and carrying all, it will be much easier to
maintain.

All the other aspects of the project have already been solved.

-----Message d'origine-----
De : Martin Gainty [mailto:[hidden email]]
Envoyé : mercredi 4 novembre 2009 00:10
À : [hidden email]
Objet : RE: Managing content in an SCXML file


Cedric

a markup implies SGML..i assume this might be described as XSD or XML Schema
Definition?
Can you describe the events this state-machine model would support?
can you describe the content each event would carry and or generate?
Can you describe what would be contained in the header for each Event?
Can you describe what the body would look like for each event?

You might be able to implement a simple listener that listens on fixed
host/port and when message is received (EOT is achieved after receiving
header and body)
you can hand the body of the message to device

can you confine the size of the message?
if not you might want to implement a packet model to buffer the packets to a
known structure
(as in some sort of linked-list)
until body EOT is achieved

sounds like a fun project!
Bon Chance
Martin Gainty
______________________________________________
Note de déni et de confidentialité
 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: [hidden email]
> To: [hidden email]
> Subject: Managing content in an SCXML file
> Date: Tue, 3 Nov 2009 23:23:01 +0100
>
> Dear Rahul and others,
>
> I want to do a quite simple thing : having a state machine on a server
> controlling user interface of mobile clients.
> The state machine would have a lot of states and complex stream, and for
> some specific states it will embedded a simple markup language content
(e.g.
> an html subset) that will be delivered to the mobile client which when it
> receives it, interpret and display it.
>
> For example the server state machine would have "connect" state that will
be

> triggered when the mobile is establishing a connection, and would react by
> giving to the mobile client the content to be displayed. An simple example
> would be :
>
> <state id="connect">
> <content>
> <title> Welcome ! </title>
> <button> text="Click here to continue" action ="send_OK"
> </button>
> <button> text="Quit" action ="send_Quit" </button>
> </content>
> <transition event="send_OK" target="next_state"/>
> <transition event="send_Quit" target="final_state"/>
> </state>
>
> In that case the content in <content> tags will be retrieved by the Java
> code on void connect() method, and sent to the device. Server will listen
to
> device and when receiving a message like send_OK, trigger this to the
state
> machine.
>
> To summarize I want to emulate a tiny web server hosting some tiny pages
> with a state machine.
>
> I've gone through all the documentation of Commons Scxml, and didn't find
an
> easy way to do this. The possible ways I see are to use a data model, but
> using <assign> tags for setting my content seems to be quite heavy to
write

> and don't know how to assign an XML tree to a data model node, and other
> possibility would be to use maybe custom actions, but how to describe in a
> simple way my XML like-content ?
>
> Do you have a suggestion to do this in an easy and readable way ?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
     
_________________________________________________________________
Windows 7: Unclutter your desktop.
http://go.microsoft.com/?linkid=9690331&ocid=PID24727::T:WLMTAGL:ON:WL:en-US
:WWL_WIN_evergreen:112009


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Ingmar Kliche

Re: Managing content in an SCXML file

Reply Threaded More More options
Print post
Permalink
In reply to this post by Rahul Akolkar
Cedric,

SCXML's default way to communicate with the outside world ist <send>. <send>
is supported by commons-SCXML and you have to implement the EventDispatcher
Interface and register it at the SCXMLExecutor to hook into the <send>
calls.

One option then would be to put the content into the body of the <send>
element, like this:

<state id="connect">
   <onentry>
      <send event="display" target="'mobiledevice'"
targettype="'mobiledevice'">
         <content>
            <title> Welcome ! </title>
            <button text="Click here to continue" action ="send_OK"/>
            <button text="Quit" action ="send_Quit"/>
          </content>
       </send>
    </onentry>
    <transition event="send_OK" target="next_state"/>
    <transition event="send_Quit" target="final_state"/>
</state>

Note that commons-SCXML currently does not implement the latest W3C working
draft. I used the syntax from a previous WD [1].

I personally haven't used it like in the example above, but I'd expect that
you would get the body of the <send> element in the EventDispachter.send()
method (in the externalNodes parameter).

The drawback of this option though is, that you can not dynamically change
the "content" at runtime (i.e. it has to be known at authoring time). If you
need to create or change the content dynamically (lets say change the button
text) you could use the namelist parameter of <send> instead and store the
content within the datamodel. Then the markup would look something like
this:

<scxml>
...
<datamodel>
   <data id="content">
      <content>
         <title> Welcome ! </title>
         <button text="Click here to continue" action ="send_OK"/>
         <button text="Quit" action ="send_Quit"/>
      </content>
   </data>
</datamodel>
...
<state id="connect">
   <onentry>
      <send event="display" target="'mobiledevice'"
targettype="'mobiledevice'" namelist="content"/>
    </onentry>
    <transition event="send_OK" target="next_state"/>
    <transition event="send_Quit" target="final_state"/>
</state>
...
</scxml>

For more information on using the datamodel look at [2]. I hope this all
addresses your question.

- Ingmar.

[1] http://www.w3.org/TR/2009/WD-scxml-20090507/#send
[2] http://commons.apache.org/scxml/guide/datamodel.html

2009/11/3 Cedric NICOLAS <[hidden email]>

> Dear Rahul and others,
>
> I want to do a quite simple thing : having a state machine on a server
> controlling user interface of mobile clients.
> The state machine would have a lot of states and complex stream, and for
> some specific states it will embedded a simple markup language content
> (e.g.
> an html subset) that will be delivered to the mobile client which when it
> receives it, interpret and display it.
>
> For example the server state machine would have "connect" state that will
> be
> triggered when the mobile is establishing a connection, and would react by
> giving to the mobile client the content to be displayed. An simple example
> would be :
>
> <state id="connect">
>        <content>
>                <title> Welcome ! </title>
>                <button> text="Click here to continue" action ="send_OK"
> </button>
>                <button> text="Quit" action ="send_Quit" </button>
> </content>
>        <transition event="send_OK" target="next_state"/>
>        <transition event="send_Quit" target="final_state"/>
> </state>
>
> In that case the content in <content> tags will be retrieved by the Java
> code on void connect() method, and sent to the device. Server will listen
> to
> device and when receiving a message like send_OK, trigger this to the state
> machine.
>
> To summarize I want to emulate a tiny web server hosting some tiny pages
> with a state machine.
>
> I've gone through all the documentation of Commons Scxml, and didn't find
> an
> easy way to do this. The possible ways I see are to use a data model, but
> using <assign> tags for setting my content seems to be quite heavy to write
> and don't know how to assign an XML tree to a data model node, and other
> possibility would be to use maybe custom actions, but how to describe in a
> simple way my XML like-content ?
>
> Do you have a suggestion to do this in an easy and readable way ?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Cedric NICOLAS

RE: Managing content in an SCXML file

Reply Threaded More More options
Print post
Permalink
Ingmar,

Thank you very much for your answer it is exactly what I was expecting, is
how to merge <content> and <send>. I will try what you suggest, and keep you
informed.

Regards,
-----Message d'origine-----
De : Ingmar Kliche [mailto:[hidden email]]
Envoyé : mercredi 4 novembre 2009 20:20
À : Commons Users List
Objet : Re: Managing content in an SCXML file

Cedric,

SCXML's default way to communicate with the outside world ist <send>. <send>
is supported by commons-SCXML and you have to implement the EventDispatcher
Interface and register it at the SCXMLExecutor to hook into the <send>
calls.

One option then would be to put the content into the body of the <send>
element, like this:

<state id="connect">
   <onentry>
      <send event="display" target="'mobiledevice'"
targettype="'mobiledevice'">
         <content>
            <title> Welcome ! </title>
            <button text="Click here to continue" action ="send_OK"/>
            <button text="Quit" action ="send_Quit"/>
          </content>
       </send>
    </onentry>
    <transition event="send_OK" target="next_state"/>
    <transition event="send_Quit" target="final_state"/>
</state>

Note that commons-SCXML currently does not implement the latest W3C working
draft. I used the syntax from a previous WD [1].

I personally haven't used it like in the example above, but I'd expect that
you would get the body of the <send> element in the EventDispachter.send()
method (in the externalNodes parameter).

The drawback of this option though is, that you can not dynamically change
the "content" at runtime (i.e. it has to be known at authoring time). If you
need to create or change the content dynamically (lets say change the button
text) you could use the namelist parameter of <send> instead and store the
content within the datamodel. Then the markup would look something like
this:

<scxml>
...
<datamodel>
   <data id="content">
      <content>
         <title> Welcome ! </title>
         <button text="Click here to continue" action ="send_OK"/>
         <button text="Quit" action ="send_Quit"/>
      </content>
   </data>
</datamodel>
...
<state id="connect">
   <onentry>
      <send event="display" target="'mobiledevice'"
targettype="'mobiledevice'" namelist="content"/>
    </onentry>
    <transition event="send_OK" target="next_state"/>
    <transition event="send_Quit" target="final_state"/>
</state>
...
</scxml>

For more information on using the datamodel look at [2]. I hope this all
addresses your question.

- Ingmar.

[1] http://www.w3.org/TR/2009/WD-scxml-20090507/#send
[2] http://commons.apache.org/scxml/guide/datamodel.html

2009/11/3 Cedric NICOLAS <[hidden email]>

> Dear Rahul and others,
>
> I want to do a quite simple thing : having a state machine on a server
> controlling user interface of mobile clients.
> The state machine would have a lot of states and complex stream, and for
> some specific states it will embedded a simple markup language content
> (e.g.
> an html subset) that will be delivered to the mobile client which when it
> receives it, interpret and display it.
>
> For example the server state machine would have "connect" state that will
> be
> triggered when the mobile is establishing a connection, and would react by
> giving to the mobile client the content to be displayed. An simple example
> would be :
>
> <state id="connect">
>        <content>
>                <title> Welcome ! </title>
>                <button> text="Click here to continue" action ="send_OK"
> </button>
>                <button> text="Quit" action ="send_Quit" </button>
> </content>
>        <transition event="send_OK" target="next_state"/>
>        <transition event="send_Quit" target="final_state"/>
> </state>
>
> In that case the content in <content> tags will be retrieved by the Java
> code on void connect() method, and sent to the device. Server will listen
> to
> device and when receiving a message like send_OK, trigger this to the
state
> machine.
>
> To summarize I want to emulate a tiny web server hosting some tiny pages
> with a state machine.
>
> I've gone through all the documentation of Commons Scxml, and didn't find
> an
> easy way to do this. The possible ways I see are to use a data model, but
> using <assign> tags for setting my content seems to be quite heavy to
write

> and don't know how to assign an XML tree to a data model node, and other
> possibility would be to use maybe custom actions, but how to describe in a
> simple way my XML like-content ?
>
> Do you have a suggestion to do this in an easy and readable way ?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]