test153.txml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?xml version="1.0"?>
  2. <!-- test that foreach goes over the array in the right order. since the array contains 1 2 3, we compare the current
  3. value with the previous value, which is stored in var1. The current value should always be larger. If
  4. it ever isn't, set Var4 to 0, indicating failure -->
  5. <scxml initial="s0" version="1.0" conf:datamodel="" xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance">
  6. <datamodel>
  7. <data conf:id="1" conf:expr="0"/> <!-- contains the previous value -->
  8. <data conf:id="2"/> <!-- the item which will contain the current value -->
  9. <data conf:id="3">
  10. <conf:array123/>
  11. </data>
  12. <data conf:id="4" conf:expr="1"/> <!-- 1 if success, 0 if failure -->
  13. </datamodel>
  14. <state id="s0">
  15. <onentry>
  16. <foreach conf:item="2" conf:arrayVar="3">
  17. <if conf:compareIDVal="1&lt;2">
  18. <assign conf:location="1" conf:varExpr="2"/>
  19. <else/>
  20. <!-- values are out of order, record failure -->
  21. <assign conf:location="4" conf:expr="0"/>
  22. </if>
  23. </foreach>
  24. </onentry>
  25. <!-- check that var1 has its original value -->
  26. <transition conf:idVal="4=0" conf:targetfail=""/>
  27. <transition conf:targetpass=""/>
  28. </state>
  29. <conf:pass/>
  30. <conf:fail/>
  31. </scxml>