On Fri, Jul 18, 2008 at 7:35 PM, Berg, T.W. (Tom) van den
<[EMAIL PROTECTED]> wrote:
> I'm still sorting out basics before moving on to some real stuff.
>
> I have a simple scxml document with a data model listed below. I execute
> my program with a custom action (also shown further below).
>
> I have a couple of questions:
>
> 1) For <assign location="Data(label, 'handle')" expr="'a test value'" />
> I get the following error. Why?
>
<snip/>
SCXML documents are namespace aware. <data> elements are recommended
to have a "root" such as:
<data name="foo">
<root xmlns="">
<!-- Note xmlns above, obviously element name
doesn't have to be root -->
</root>
</data>
Can you try that -- it may solve some of the questions below. Then we
can look at the remaining ones, if any.
-Rahul
> 19-jul-2008 1:15:51 org.apache.commons.scxml.Builtin dataNode
> WARNING: Data(): No nodes matching the XPath expression "handle",
> returning null
> 19-jul-2008 1:15:51 org.apache.commons.scxml.model.Assign execute
> SEVERE: <assign>: location does not point to a <data> node
>
> 2) Also for <rti:register name="result" expr="Data(label,'name')"/> I
> get an error. Why?
>
> 19-jul-2008 1:15:51 sc.Register execute
> INFO: eval(Data(label,'name'))
> 19-jul-2008 1:15:51 org.apache.commons.scxml.Builtin dataNode
> WARNING: Data(): No nodes matching the XPath expression "name",
> returning null
> 19-jul-2008 1:15:51 sc.Register execute
> INFO: <var>: Defined variable 'result' with initial value ''
>
> 3) How can I transer the result from rti:register back into the
> datamodel's handle field from a) the SCXML document or b) the custom
> action?
>
>
> Thanks -- Tom
>
> ----
>
> <?xml version="1.0"?>
> <scxml xmlns="http://www.w3.org/2005/07/scxml"
> xmlns:rti="http://rti.actions/CUSTOM"
> version="1.0"
> initialstate="SyncPoint">
>
> <state id="SyncPoint">
>
> <datamodel>
> <data name="label">
> <name>initial</name>
> <handle></handle>
> </data>
> </datamodel>
>
> <initial>
> <transition target="registered"/>
> </initial>
>
> <state id="registered">
> <onentry>
> <assign location="Data(label, 'handle')" expr="'a test value'" />
> <rti:register name="result" expr="Data(label,'name')"/>
> <rti:register name="result" expr="2 + 8"/>
> </onentry>
> <transition event="confirmed" target="confirmed"/>
> <transition event="error" target="error"/>
> </state>
>
> <state id="confirmed">
> <onentry>
> <rti:confirm name="doConfirm" />
> </onentry>
> <transition target="end"/>
> <transition event="error" target="error"/>
> </state>
>
> <final id="end"/>
>
> <state id="error"></state>
> </state>
>
> </scxml>
>
> ----
>
> public class Register extends Action {
>
> <<... cut ...>>
>
> public void execute(final EventDispatcher evtDispatcher,
> final ErrorReporter errRep, final SCInstance scInstance,
> final Log appLog, final Collection derivedEvents)
> throws ModelException, SCXMLExpressionException {
>
> Context ctx = scInstance.getContext(getParentState());
> Evaluator eval = scInstance.getEvaluator();
>
> ctx.setLocal(getNamespacesKey(), getNamespaces());
>
> appLog.info("eval("+expr+")");
>
> Object varObj = eval.eval(ctx, expr);
>
> ctx.setLocal(getNamespacesKey(), null);
> ctx.setLocal(name, varObj);
>
> appLog.info("<var>: Defined variable '" + name + "' with initial value
> '" + String.valueOf(varObj) + "'");
>
> TriggerEvent ev = new TriggerEvent(name + ".change",
> TriggerEvent.CHANGE_EVENT);
> derivedEvents.add(ev);
> }
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]