commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r560379 - in /jakarta/commons/proper/scxml/trunk: src/main/java/org/apache/commons/scxml/model/ src/test/java/org/apache/commons/scxml/model/ xdocs/guide/
Date Fri, 27 Jul 2007 20:57:41 GMT
Author: rahul
Date: Fri Jul 27 13:57:40 2007
New Revision: 560379

URL: http://svn.apache.org/viewvc?view=rev&rev=560379
Log:
Delete existing child nodes before adding new ones (<assign> semantics)
SCXML-51

Modified:
    jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Assign.java
    jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/AssignTest.java
    jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/assign-test.xml
    jakarta/commons/proper/scxml/trunk/xdocs/guide/datamodel.xml

Modified: jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Assign.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Assign.java?view=diff&rev=560379&r1=560378&r2=560379
==============================================================================
--- jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Assign.java
(original)
+++ jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Assign.java
Fri Jul 27 13:57:40 2007
@@ -195,8 +195,14 @@
                     } else {
                         newNode = eval.evalLocation(ctx, expr);
                     }
+                    // Remove all children
+                    for (Node child = oldNode.getFirstChild();
+                            child != null;
+                            child = child.getNextSibling()) {
+                        oldNode.removeChild(child);
+                    }
                     if (newNode != null) {
-                        // adopt children, possible spec clarification needed
+                        // Adopt new children
                         for (Node child = newNode.getFirstChild();
                                 child != null;
                                 child = child.getNextSibling()) {

Modified: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/AssignTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/AssignTest.java?view=diff&rev=560379&r1=560378&r2=560379
==============================================================================
--- jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/AssignTest.java
(original)
+++ jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/AssignTest.java
Fri Jul 27 13:57:40 2007
@@ -69,7 +69,7 @@
     public void testAssignSrc() {
         Set currentStates = exec.getCurrentStatus().getStates();
         assertEquals(1, currentStates.size());
-        assertEquals("assign2", ((State)currentStates.iterator().
+        assertEquals("assign3", ((State)currentStates.iterator().
             next()).getId());
         assertTrue(exec.getCurrentStatus().isFinal());
     }

Modified: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/assign-test.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/assign-test.xml?view=diff&rev=560379&r1=560378&r2=560379
==============================================================================
--- jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/assign-test.xml
(original)
+++ jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/assign-test.xml
Fri Jul 27 13:57:40 2007
@@ -17,6 +17,7 @@
 -->
 <!-- Test "src" attribute of assign element -->
 <scxml xmlns="http://www.w3.org/2005/07/scxml"
+       xmlns:rad="http://foo/bar"
        version="1.0"
        initialstate="assign1">
   
@@ -44,6 +45,26 @@
 
   </state>
 
-  <state id="assign2" final="true" />
+  <state id="assign2">
+
+    <datamodel>
+      <data name="jira51data1">
+          <rad:timeout>10</rad:timeout>
+      </data> 
+      <data name="jira51data2">
+          <rad:short xmlns="">20</rad:short>
+      </data>
+    </datamodel>
+
+    <onentry>
+        <assign location="Data(jira51data1,'rad:timeout')" expr="Data(jira51data2,'rad:short')"/>
+    </onentry>
+
+    <transition cond="Data(jira51data1,'rad:timeout') eq 20"
+                target="assign3" />
+
+  </state>
+
+  <state id="assign3" final="true"/>
 
 </scxml>

Modified: jakarta/commons/proper/scxml/trunk/xdocs/guide/datamodel.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/xdocs/guide/datamodel.xml?view=diff&rev=560379&r1=560378&r2=560379
==============================================================================
--- jakarta/commons/proper/scxml/trunk/xdocs/guide/datamodel.xml (original)
+++ jakarta/commons/proper/scxml/trunk/xdocs/guide/datamodel.xml Fri Jul 27 13:57:40 2007
@@ -256,11 +256,13 @@
       &lt;assign location="Data(carrental, 'car/dates')"
                  expr="Data(hotelbooking, 'hotel/stay')" /&gt;
 
-      &lt;!-- copies over all children of &lt;stay&gt;, the
-              &lt;startdate&gt; and &lt;enddate&gt; in this case --&gt;
+      &lt;!-- deletes all children of &lt;dates&gt; and then copies
+              over all children of &lt;stay&gt;, the &lt;startdate&gt;
+              and &lt;enddate&gt; in this case --&gt;
     </pre>
-    In these cases, the node pointed by the expression is first cloned, and
-    then added as a child node to the node the lvalue points to.</p>
+    In these cases, the children of the node pointed by the expression are
+    first cloned, and then added as children to the node the lvalue points
+    to.</p>
     </li>
 
    </ol>



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


Mime
View raw message