commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pascal Ravot <pascal.ra...@mcc-soft.com>
Subject Re: [SCXML] - XPATH
Date Thu, 05 Jun 2008 09:47:12 GMT
Excellent
Many Thks Lawrence

Yau Lawrence wrote:
> Hello Pascal,
> The simplest way to correct the problem is to change your datamodel definition to use
an unnamed namespace for your poolconfiguration XML tree:
>
> ...
> <data name="poolconfiguration">
>         <foo xmlns="">  <!-- override SCXML namespace -->
>                 <dir>toto</dir>
>                 <freq>1</freq>
>         </foo>
> </data>
> ...
>
> Then your xpath expression will work.  I tested your SCXML document just to be sure.
>
> Hope this helps,
> Lawrence
>
>
> -----Original Message-----
> From: Pascal Ravot [mailto:pascal.ravot@mcc-soft.com]
> Sent: 05 June 2008 9:26
> To: user@commons.apache.org
> Subject: SCXML - XPATH
>
> Hello,
> I'm a perfect newbie to sxcml, so i'm probably asking stupid questions !
>
> I'm trying to get access to the content of a datamodel from within the scxml document
and a custom action :
> Here is the dummy state machine:
>
>      <scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0"
>          xmlns:mc="http://com.mccsoft.scxml/action" initialstate="start">
>          <!--  Defining global data  -->
>          <datamodel>
>              <data name="timeout" expr="1" />
>              <data name="counter" expr="1" />
>              <data name="poolconfiguration">
>                  <foo>
>                      <dir>toto</dir>
>                      <freq>1</freq>
>                  </foo>
>              </data>
>          </datamodel>
>          <!-- State machine starts here -->
>          <state id="start">
>              <onentry>
>                  <log
>                      expr="Data(poolconfiguration, 'foo/dir')"
>                  />
>              </onentry>
>              <transition target="now_waiting" />
>          </state>
>          <state id="now_waiting">
>              <onentry>
>                  <log expr="Counter is now counter" />
>              </onentry>
>              <onentry>
>                  <mc:wait timeoutName="timeout" conf="poolconfiguration"/>
>                  <assign name="counter" expr="counter +1" />
>                  <log
>                      expr="'Timeout is ' + timeout + ' Counter is ' + counter " />
>              </onentry>
>              <transition target="now_waiting" />
>          </state>
>
>      </scxml>
>
> Regarding execution environment everything is copied from samples  using Jexl :
>
>              exec = new SCXMLExecutor(new JexlEvaluator(),
>                      new SimpleDispatcher(), new SimpleErrorReporter());
>              exec.setStateMachine(scxml);
>              exec.setRootContext(new JexlContext());
>
> I've got a custom action <mc:wait ...> that get the name of the data entry to inspect...
> Within the execute of the action i'm trying to do roughly but with java the equivalent
of <log expr="Data(poolconfiguration, 'foo/dir')" />
>
> -->
>          scInstance.getEvaluator().eval(
>                      scInstance.getRootContext(), "Data(" + conf + ",'foo/dir')");
>
>
> My objective is to be able to access sub elements of a defined data (in this case poolconfiguration/foo/dir)
of a top level datamodel.
> and that either by scxml script or within custom action.
>
> Unfortunately, none of those evaluation is returning the expected "toto".
>
> I got in the log :
> 1922 [main] DEBUG org.apache.commons.jexl.ExpressionFactory  - Parsing
> expression: _builtin.data(_ALL_NAMESPACES, poolconfiguration, 'foo/dir'); 4500 [main]
WARN org.apache.commons.scxml.Builtin  - Data(): No nodes matching the XPath expression "foo/dir",
returning null
>
> or
> 126125 [main] DEBUG org.apache.commons.scxml.Builtin  - Turning off namespaced XPath
evaluation since no namespace information is available for path: foo/dir 126140 [main] WARN
org.apache.commons.scxml.Builtin  - Data(): No nodes matching the XPath expression "foo/dir",
returning null
>
> (for the custom action).
>
> The strange point is that, after debugging this sample, it appeared that the poolconfiguration
node is correctly extracted by the Data expression. I mean the datanode found in the _builtin
seems ok (with childs, sieblings...), but this piece of code  (org.apache.commons.scxml.Builtin.java):
> result = XPathAPI.selectNodeList(dataNode, path); returns an empty list.
>
> It is most obvious (to everybody except me) that i've probably spelled the XPATH in an
incorrect way, but i've tried may path without success ( '//dir', '/data/foo/dir',
> 'data/foo/dir'...)
>
> So any help or idea is welcomed !!!!
>
> By advance thanks.
>
> P. Ravot.
>
> ---------------------------------------------------------------------
> 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
>
>
>
>   

-- 

*Pascal Ravot*

/Partner Manager/

------------------------------------------------------------------------

*M*essage *C*ommunication *C*onseil *SAS*
35 rue Chanzy
Paris F-75011 France
Phone : 33 1 44 93 24 24

*M*CC *L*AB *I*NFO *SRL*
Punct de lucru: Bucuresti, Sector 3,
Str. Corneliu Coposcu nr 3, bl 101

email : pascal.ravot@mcc-soft.com <mailto:pascal.ravot@mcc-soft.com>
Web : http://www.mcc-soft.com <http://www.mcc-soft.com/>

------------------------------------------------------------------------

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


Mime
View raw message