diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2012-09-08 23:26:39 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2012-09-08 23:26:39 (GMT) |
commit | aa6c3a1257a29cc5bcf8b94893732ee553f27582 (patch) | |
tree | 625adb1a353a17ffed2c7e0bac686d705aaec93f /test/samples/apache/datamodel-01.xml | |
download | uscxml-aa6c3a1257a29cc5bcf8b94893732ee553f27582.zip uscxml-aa6c3a1257a29cc5bcf8b94893732ee553f27582.tar.gz uscxml-aa6c3a1257a29cc5bcf8b94893732ee553f27582.tar.bz2 |
Initial upload
Still somewhat quirky to build but fairly feature complete
Diffstat (limited to 'test/samples/apache/datamodel-01.xml')
-rw-r--r-- | test/samples/apache/datamodel-01.xml | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/test/samples/apache/datamodel-01.xml b/test/samples/apache/datamodel-01.xml new file mode 100644 index 0000000..cc874fb --- /dev/null +++ b/test/samples/apache/datamodel-01.xml @@ -0,0 +1,107 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- A fictitious state machine used by test cases. + Meant to illustrate the usage of SCXML <datamodel> element + and the Commons SCXML Data() function --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="main"> + + <!-- Root or document datamodel --> + <datamodel> + <data id="docdata"> + <root xmlns=""> + <foo>foo</foo> + </root> + </data> + </datamodel> + + <state id="main"> + + <initial> + <transition target="ten"/> + </initial> + + <!-- datamodel scoped to state "main" --> + <datamodel> + <data id="mainvar" expr="${0}" /> + <data id="maindata"> + <root xmlns=""> + <foo> + <bar>bar</bar> + </foo> + </root> + </data> + </datamodel> + + <state id="ten"> + <onentry> + <!-- Assign Usage 1: name is previously defined + <var> or degenerate <data> (as in this case) --> + <assign name="mainvar" expr="${10}" /> + </onentry> + <!-- Commons SCXML defines a Data() function to use in conjunction + with the Commons EL expression language. The + first argument is the named XML data tree and the second is + the XPath expression to a node whose value is to be + examined --> + <transition event="ten.done" + cond="${mainvar eq 10 and Data(maindata,'root/foo/bar') eq 'bar'}" + target="twenty" /> + <onexit> + <!-- Assign Usage 2: location must point to an existing + node --> + <assign location="${Data(maindata,'root/foo/bar')}" expr="baz" /> + </onexit> + </state> + + <state id="twenty"> + <onentry> + <assign name="mainvar" expr="${20}" /> + </onentry> + <transition event="twenty.done" + cond="${Data(maindata,'root/foo/bar') eq 'baz' and mainvar eq 20}" + target="thirty" /> + <onexit> + <!-- Assign Usage 3: location points to an existing + node, and expr points to an existing node. + In this case, location adopts expr's child nodes. --> + <assign location="${Data(docdata,'root/foo')}" + expr="${Data(maindata,'root/foo')}" /> + <assign location="${Data(docdata,'root/foo/bar')}" + expr="${10}" /> + </onexit> + </state> + + <state id="thirty"> + <!-- Arithmetic operations are possible with results from + the Data() function. Note that data "docdata" + did not have a node at 'root/foo/bar' to begin with, + the XML tree was manipulated by the <assign> above --> + <transition event="thirty.done" + cond="${Data(docdata,'root/foo/bar') gt 5}" + target="forty" /> + </state> + + <state id="forty" final="true" /> + + </state> + +</scxml> + + |