1

I am using SCXML in my java application. I am using apache-commons-scxml api to implement the state machine. I am able to set the value in data model through sxml api but not able to read that value in java code.

Each time read operation fetch the default value that is set in scxml document instead of reading the latest value that is set at runtime. However if we log the expression in scxml doc for the same value then it will print the updated value but in java code I am not able to get the updated value.

Below is the datamodel:

<datamodel><!-- Usage where the value is an XML data tree -->           
   <data id="XYZ">
      <A xmlns="">T</DevID> 
      <B xmlns="">F</Result>            
   </data>
</datamodel>

Reading the data model:

List<Data> dataTest = handlerFSM.getEngine().getStateMachine().getDatamodel().getData();
Iterator<Data> itrTest = dataTest.iterator();
while(itrTest.hasNext()){
  Data d = itrTest.next();
  if(d.getId().equals("XYZ")){
  NodeList nodeList = d.getNode().getChildNodes();
}

Setting the value:

nodeList.item(1).setTextContent("dummy");

Reading the value:

nodeList1.item(1).getTextContent();

All the time read operation gives the value "F" not "dummy" that is set at runtime. Any idea how to read the updated value(in this case "dummy") of the node in java code through apache commons-scxml api?

4

1 回答 1

0

你可以这样做:

org.w3c.dom.Node xyz = (org.w3c.dom.Node) handlerFSM.getEngine().getRootContext().get("xyz");

xyz.getFirstChild().setTextContent("dummy");

据我了解,getStateMachine().getDataModel() 只会为您提供 XML 文件中定义的静态数据模型。

于 2015-04-27T10:58:54.840 回答