2011/2/23 Gavin Lei <gavingui2...@gmail.com>:
> Hi guys,
> Do Apache Commons SCXML support XInclude and XPath 2.0? Today i want
> to do some experiments to confirm this, but it seems that Commons
> SCXML does not support XInclude and XPath 2.0.
> 1. about XInclude
> I try to run such a SCXML document in Commons SCXML engine:
>
> <scxml initial="s1" xmlns:xi="http://www.w3.org/2001/XInclude";>
> <xi:include href="datamodel.xml" parse="xml"/>
> <state id="s1">
> <onentry>
> <script>x = x + 5;</script>
> </onentry>
>        <transition cond="x &gt; 1" target="print">
> </transition>
>    </state>
>    <state id="print">
>     <onexit>
>     <log label="Result" expr="x"/>
>     </onexit>
>     <transition event="result" target="result" />
>    </state>
>   <final id="result"/>
> </scxml>
>
> datamodel.xml:
>
> <datamodel>
> <data id="x" expr="1"/>
> </datamodel>
>
> But it seems that Commons SCXML does not work for me. So, i want to
> confirm that Commons SCXML support XInclude or not.
>
<snip/>

It (the last release) doesn't, but it won't be difficult to add. The
last release used Commons Digester for parsing. Since then, Digester
has added XInclude support, so the actual change now necessary to the
SCXMLParser class is minimal.

It may be possible to parse documents containing XInclude using the
new and unreleased parser class (i.e. SCXMLReader in the J6 branch in
SVN) by passing the appropriate inputs/options to the StAX parser.


> 2, about XPath 2.0
> In W3C's SCXML recommendation specification, it show that SCXML engine
> should support XPath 2.0 and XPath 2.0 functions. And i tried a SCXML
> document with this State in it:
>
> <state id="errorSwitch" xmlns:fn="http://www.w3.org/2005/xpath-functions";>
>  <datamodel>
>    <data id="time"/>
>  </datamodel>
>
>  <onentry>
>    <assign location="$time" expr="fn:current-dateTime()"/>
>  </onentry>
>
>  <transition cond="fn:year-from-dateTime($time) > 2009" target="newBehavior"/>
>  <transition target="currentBehavior"/>
> </state>
>
>
>
> But it seems that Commons SCXML does not work for me too. I think
> XInclude and XPath support are both very importmant in SCXML
> application.  So i want to confirm Commons SCXML support these
> features or not. If yes, how can we use them ? If not, may be we can
> do something to improve Commons SCXML. Thank You.
>
<snap/>

You may use an XPathEvaluator like the one below and pass in the
functions you want supported (see 2nd constructor which takes a map,
for how arbitrary XPath functions support may be added):

http://svn.apache.org/repos/asf/commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/env/xpath/XPathEvaluator.java

-Rahul


> --
> ---------------------------------
> Best Regards
> Gavin Lei (雷银)
> Email: gavingui2...@gmail.com
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to