commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Linda Erlenhov <linda.erlen...@gmail.com>
Subject Re: [SCXML] Polling in datamodel
Date Mon, 11 May 2009 13:28:22 GMT
Hello!

The thing here is that the value is never a DOM node. Hence my question. I
previousley asked why the "assign location" didn´t call for the "set"
function in the Context and got the answere that the "assign location"
doesn´t work as "assign name", "assign name" calls the set function and sets
a variable, "assign location" manipulates the XML tree as it is. The advice
was to make an "custom action" instead or do the ugly hack I did: do an
"assign name" with the name after the "assign location" has executed.
What I wanted to know is if there is any way of fetching the "tree" or
whatever it is to get the data associatet to a name, according to the model
below.
If you look at my example below, I will always "know" the name of the
datamodel in this case: "DynamicData", and I will recieve the "name" of the
specific tag in this data, in this case "Data_1", "Data_2" or "Data_3". In
my model below I have done an ugly way of finding out what the value is but
i realized that that was not enough, i need to know the "type" aswell. And
that I don´t know how to find.

Does anybody have a solution to this, or some kind of idea on how to solve
this?

best regards
//Linda

On Tue, May 5, 2009 at 3:50 PM, Ingmar Kliche
<ingmar.kliche@googlemail.com>wrote:

> Linda,
> you should be able to use the DOM API to read the values. In
> context.set(name, value) you should check whether the value is a DOM node:
>
> import import org.w3c.dom.Node;
>
> ...
> ... set(String name, Object value) {
>
>        if (value instanceof Node) {
>            Node nodeValue = (Node) value;
>        }
>
> scope.put(name, scope, value);
>
>
> 2009/5/5 Linda Erlenhov <linda.erlenhov@gmail.com>
>
> > Hello.
> > I´m back with another thousand questions!
> >
> > Still with my datamodel like this:
> > ------------------------------------
> > <scxml version="1.0" initialstate="176" xmlns:cs="
> > http://commons.apache.org/scxml" xmlns="http://www.w3.org/2005/07/scxml
> ">
> >
> > <datamodel>
> > <data name="DynamicData">
> > <Data_1 xmlns="" id="1" type="Integer">0</Data_1>
> > <Data_2 xmlns="" id="2" type="Integer">0</Data_2>
> > <Data_3 xmlns="" id="3" type="String">none</Data_2>
> > </data>
> > <data name="DDChange"/>
> > <data name="DDValue"/>
> > <data name="DDType"/>
> > <data name="Indication_1" expr="false"/>
> > </datamodel>
> > .......................................snip.......
> > Later on i set the data:
> > ...........................................snip.....
> > <state id="StateB">
> > <onentry>
> > <log label="Renegade" expr="'Entering state: StateB'"/>
> > <log label="Renegade" expr="Data(DynamicData,'Data_1')"/>
> > <assign location="Data(DynamicData,'Data_1')"
> > expr="Data(DynamicData,'Data_1')+1"/>
> > <assign name="DDValue" expr="Data(DynamicData,'Data_1')"/>
> > <assign name="DDChange" expr="'Data_1'"/>
> > <log label="Renegade" expr="Data(DynamicData,'Data_1')"/>
> >
> > </onentry>
> > ..........snip--------------------
> >
> > So now here´s the problem.
> >
> > As you see I haven´t used the custom action, but an rather ugly hack
> where
> > I
> > do an assign name after I do the assign location to trigger a call to the
> > "set" function in the context.
> >
> > In this version I also do another assign where I assign another name with
> > the value. All my data are named Data_XX so i screen the calls to set byt
> > looking for the ones that are named Data_XX. When I recieve a call for
> > Data_XX I would like to know what the value is, which I in this case have
> > solved by assigning another variable with it earlier, when i get a "set"
> > call named Data_xx i know that the variable DDValue contains the value of
> > this data. Not pretty, but OK and working so far.
> > Now I would like to be able to see what "type" the data is aswell. How do
> I
> > do that? And: Is there a less spaghetti way to poll the value of the data
> > from where I am (In the context) when I have the "name" of it. (The name
> in
> > this case is Data_1, Data_2 or Data_3, I also know that the data=name is
> > DynamicData) .
> >
> > Due to lack of time I would prefer if i wouldn´t have to "redo" to much
> of
> > the scxml, but is this possible to do it my way otherwise? Or do I have
> to
> > do it over.
> >
> > Best Regards
> > //Linda
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message