You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Wolfgang Frech (JIRA)" <ji...@apache.org> on 2007/02/12 17:53:06 UTC

[jira] Created: (SCXML-38) spec and semantics of initialstate attribute not clear for external state

spec and semantics of initialstate attribute not clear for external state
-------------------------------------------------------------------------

                 Key: SCXML-38
                 URL: https://issues.apache.org/jira/browse/SCXML-38
             Project: Commons SCXML
          Issue Type: Bug
    Affects Versions: 0.6
         Environment: Win XP, Java 5, Eclipse 3.2, JUnit 4
            Reporter: Wolfgang Frech
            Priority: Minor


The WD-SCXML is not fully consistent if the initialstate attribute is required for an external state, that is a state that has a src attribute pointing to a file containing its content.

The attribute details (WD 3.1.1) define the initialstate attribute as required, without any exception for external states.
The example Test2Sub1.scxml (WD F.1) does not have a initialstate attribute.

If this is only a minor omission in the example, the real issue is: how does an initialstate attribute affect the behavior of the state chart?

So far this would be only an issue with the WD.
The commons SCXML implementation decided to treat the initialstate attribute as required.
Demonstration code follows.

The issue with the commons implementation is:
It is not clear which (state) id can be given in the initialstate attribute of an external state SCXML file and what this means.

The id of the external state itself is not accepted. See second demonstration code.


Demo - initialstate required:
----
	@Test
	public void externalStateWithoutInitialstate() throws FileNotFoundException,
			IOException, SAXException, ModelException {
		final URL definition = getClass().getClassLoader().getResource(
				"externalStateWithoutInitialstate-main.scxml");
		try {
			SCXMLDigester.digest(definition, new SimpleErrorHandler());
			fail();
		} catch (ModelException e) {
			assertEquals(
					"Initial state null or not a descendant of state with ID \"start\"",
					e.getMessage());
		}
	}
----

main scxml
----
<?xml version="1.0"?>
<scxml
  xmlns="http://www.w3.org/2005/07/scxml"
  version="1.0"
  initialstate="start">
  <state id="start" src="externalStateWithoutInitialstate-external.scxml"/>
</scxml>
----

included scxml 
note: no initalstate
----
<?xml version="1.0"?>
<scxml
  xmlns="http://www.w3.org/2005/07/scxml"
  version="1.0">
  <state id="start" />
</scxml>



Demo - with initialstate pointing to external state
-----
	@Test
	public void externalStateWithInitialstate() throws FileNotFoundException,
			IOException, SAXException, ModelException {
		final URL definition = getClass().getClassLoader().getResource(
				"externalStateWithInitialstate-main.scxml");
		try {
			SCXMLDigester.digest(definition, new SimpleErrorHandler());
			fail();
		} catch (ModelException e) {
			assertEquals(
					"Initial state null or not a descendant of state with ID \"start\"",
					e.getMessage());
		}
	}
-----


main scxml
-----
<?xml version="1.0"?>
<scxml
  xmlns="http://www.w3.org/2005/07/scxml"
  version="1.0"
  initialstate="start">
  <state id="start" src="externalStateWithInitialstate-external.scxml"/>
</scxml>
----


included scxml
note: with initialstate
----
<?xml version="1.0"?>
<scxml
  xmlns="http://www.w3.org/2005/07/scxml"
  version="1.0"
  initialstate="start">
  <state id="start">
    <onentry>
      <log expr="'now in state start'" />
    </onentry>
  </state>
</scxml>
----

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (SCXML-38) spec and semantics of initialstate attribute not clear for external state

Posted by "Wolfgang Frech (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SCXML-38?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12472340 ] 

Wolfgang Frech commented on SCXML-38:
-------------------------------------

continued...

In a external state with a substate, the initialstate attribute does not replace the initial child.


Demo
-----
	@Test
	public void externalStateWithInitialSubstate() throws FileNotFoundException,
			IOException, SAXException, ModelException {
		final URL definition = getClass().getClassLoader().getResource(
				"externalStateWithInitialSubstate-external.scxml");
		try {
			SCXMLDigester.digest(definition, new SimpleErrorHandler());
			fail();
		} catch (ModelException e) {
			assertEquals(
					"No initial element available for state with ID \"start\"",
					e.getMessage());
		}
	}
-----
<?xml version="1.0"?>
<scxml
  xmlns="http://www.w3.org/2005/07/scxml"
  version="1.0"
  initialstate="start">
  <state id="start" src="externalStateWithInitialstate-external.scxml"/>
</scxml>
-----
<?xml version="1.0"?>
<scxml
  xmlns="http://www.w3.org/2005/07/scxml"
  version="1.0"
  initialstate="start">
  <state id="start">
    <onentry>
      <log expr="'now in state start'" />
    </onentry>
  </state>
</scxml>
-----



> spec and semantics of initialstate attribute not clear for external state
> -------------------------------------------------------------------------
>
>                 Key: SCXML-38
>                 URL: https://issues.apache.org/jira/browse/SCXML-38
>             Project: Commons SCXML
>          Issue Type: Bug
>    Affects Versions: 0.6
>         Environment: Win XP, Java 5, Eclipse 3.2, JUnit 4
>            Reporter: Wolfgang Frech
>            Priority: Minor
>
> The WD-SCXML is not fully consistent if the initialstate attribute is required for an external state, that is a state that has a src attribute pointing to a file containing its content.
> The attribute details (WD 3.1.1) define the initialstate attribute as required, without any exception for external states.
> The example Test2Sub1.scxml (WD F.1) does not have a initialstate attribute.
> If this is only a minor omission in the example, the real issue is: how does an initialstate attribute affect the behavior of the state chart?
> So far this would be only an issue with the WD.
> The commons SCXML implementation decided to treat the initialstate attribute as required.
> Demonstration code follows.
> The issue with the commons implementation is:
> It is not clear which (state) id can be given in the initialstate attribute of an external state SCXML file and what this means.
> The id of the external state itself is not accepted. See second demonstration code.
> Demo - initialstate required:
> ----
> 	@Test
> 	public void externalStateWithoutInitialstate() throws FileNotFoundException,
> 			IOException, SAXException, ModelException {
> 		final URL definition = getClass().getClassLoader().getResource(
> 				"externalStateWithoutInitialstate-main.scxml");
> 		try {
> 			SCXMLDigester.digest(definition, new SimpleErrorHandler());
> 			fail();
> 		} catch (ModelException e) {
> 			assertEquals(
> 					"Initial state null or not a descendant of state with ID \"start\"",
> 					e.getMessage());
> 		}
> 	}
> ----
> main scxml
> ----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0"
>   initialstate="start">
>   <state id="start" src="externalStateWithoutInitialstate-external.scxml"/>
> </scxml>
> ----
> included scxml 
> note: no initalstate
> ----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0">
>   <state id="start" />
> </scxml>
> Demo - with initialstate pointing to external state
> -----
> 	@Test
> 	public void externalStateWithInitialstate() throws FileNotFoundException,
> 			IOException, SAXException, ModelException {
> 		final URL definition = getClass().getClassLoader().getResource(
> 				"externalStateWithInitialstate-main.scxml");
> 		try {
> 			SCXMLDigester.digest(definition, new SimpleErrorHandler());
> 			fail();
> 		} catch (ModelException e) {
> 			assertEquals(
> 					"Initial state null or not a descendant of state with ID \"start\"",
> 					e.getMessage());
> 		}
> 	}
> -----
> main scxml
> -----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0"
>   initialstate="start">
>   <state id="start" src="externalStateWithInitialstate-external.scxml"/>
> </scxml>
> ----
> included scxml
> note: with initialstate
> ----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0"
>   initialstate="start">
>   <state id="start">
>     <onentry>
>       <log expr="'now in state start'" />
>     </onentry>
>   </state>
> </scxml>
> ----

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (SCXML-38) spec and semantics of initialstate attribute not clear for external state

Posted by "Wolfgang Frech (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SCXML-38?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12472560 ] 

Wolfgang Frech commented on SCXML-38:
-------------------------------------

ad b) non-unique state ids
My test cases use the same ID intentionally.
I read the WD that the state element is present in both the including and the included external file, with the same ID.
This follows the example in the Working Draft, section F.1 Language Overview

In the main SCXML document, the state "Test2Sub1" is externalized like that:
----
...
      <!-- This time we reference a state 
           -    defined in an external file -->
      <state id="Test2Sub1" src="Test2Sub1.scxml"/>
...
----
and defined in the external file like that.
----
...
<scxml version="1.0" xmlns="http://www.w3.org/2005/07/scxml"> 
...
 <state id="Test2Sub1">
    <onentry>
      <log expr="'Inside Test2Sub1'"/>
     </onentry>
    <transition event="Event2" target="Test2Sub2"/>
  </state>
</scxml>
----

> spec and semantics of initialstate attribute not clear for external state
> -------------------------------------------------------------------------
>
>                 Key: SCXML-38
>                 URL: https://issues.apache.org/jira/browse/SCXML-38
>             Project: Commons SCXML
>          Issue Type: Bug
>    Affects Versions: 0.6
>         Environment: Win XP, Java 5, Eclipse 3.2, JUnit 4
>            Reporter: Wolfgang Frech
>            Priority: Minor
>
> The WD-SCXML is not fully consistent if the initialstate attribute is required for an external state, that is a state that has a src attribute pointing to a file containing its content.
> The attribute details (WD 3.1.1) define the initialstate attribute as required, without any exception for external states.
> The example Test2Sub1.scxml (WD F.1) does not have a initialstate attribute.
> If this is only a minor omission in the example, the real issue is: how does an initialstate attribute affect the behavior of the state chart?
> So far this would be only an issue with the WD.
> The commons SCXML implementation decided to treat the initialstate attribute as required.
> Demonstration code follows.
> The issue with the commons implementation is:
> It is not clear which (state) id can be given in the initialstate attribute of an external state SCXML file and what this means.
> The id of the external state itself is not accepted. See second demonstration code.
> Demo - initialstate required:
> ----
> 	@Test
> 	public void externalStateWithoutInitialstate() throws FileNotFoundException,
> 			IOException, SAXException, ModelException {
> 		final URL definition = getClass().getClassLoader().getResource(
> 				"externalStateWithoutInitialstate-main.scxml");
> 		try {
> 			SCXMLDigester.digest(definition, new SimpleErrorHandler());
> 			fail();
> 		} catch (ModelException e) {
> 			assertEquals(
> 					"Initial state null or not a descendant of state with ID \"start\"",
> 					e.getMessage());
> 		}
> 	}
> ----
> main scxml
> ----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0"
>   initialstate="start">
>   <state id="start" src="externalStateWithoutInitialstate-external.scxml"/>
> </scxml>
> ----
> included scxml 
> note: no initalstate
> ----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0">
>   <state id="start" />
> </scxml>
> Demo - with initialstate pointing to external state
> -----
> 	@Test
> 	public void externalStateWithInitialstate() throws FileNotFoundException,
> 			IOException, SAXException, ModelException {
> 		final URL definition = getClass().getClassLoader().getResource(
> 				"externalStateWithInitialstate-main.scxml");
> 		try {
> 			SCXMLDigester.digest(definition, new SimpleErrorHandler());
> 			fail();
> 		} catch (ModelException e) {
> 			assertEquals(
> 					"Initial state null or not a descendant of state with ID \"start\"",
> 					e.getMessage());
> 		}
> 	}
> -----
> main scxml
> -----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0"
>   initialstate="start">
>   <state id="start" src="externalStateWithInitialstate-external.scxml"/>
> </scxml>
> ----
> included scxml
> note: with initialstate
> ----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0"
>   initialstate="start">
>   <state id="start">
>     <onentry>
>       <log expr="'now in state start'" />
>     </onentry>
>   </state>
> </scxml>
> ----

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (SCXML-38) spec and semantics of initialstate attribute not clear for external state

Posted by "Wolfgang Frech (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SCXML-38?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12472350 ] 

Wolfgang Frech commented on SCXML-38:
-------------------------------------

continued....

The actual behavior is: When the external state is entered (that is the parent state), the initialstate attribute takes precedence over the target of the transition in the initial attribute.

This can be explained like this: As the initialstate attribute is honored, the state chart goes directly into the specified substate. It does not enter the parent state per se, so it does not enter the initial element of the parent state, and does not execute the unconditional transition in it either.


Demo code

----
	@Test
	public void externalStateWithConflictingInitialstate()
			throws FileNotFoundException, IOException, SAXException, ModelException {
		final URL definition = getClass().getClassLoader().getResource(
				"externalStateWithConflictingInitialstate-external.scxml");
		SCXML model = SCXMLDigester.digest(definition, new SimpleErrorHandler());
		SCXMLExecutor executor = new SCXMLExecutor();
		executor.setStateMachine(model);
		executor.setRootContext(new SimpleContext());
		executor.setEvaluator(new ELEvaluator());
		executor.setErrorReporter(new SimpleErrorReporter());
		executor.go();
		State state = (State) (executor.getCurrentStatus().getStates().iterator()
				.next());
		assertEquals("one", state.getId());
	}	
----
<?xml version="1.0"?>
<scxml
  xmlns="http://www.w3.org/2005/07/scxml"
  version="1.0"
  initialstate="start">
  <state
    id="start"
    src="externalStateWithConflictingInitialstate-external.scxml" />
</scxml>
----
<?xml version="1.0"?>
<scxml
  xmlns="http://www.w3.org/2005/07/scxml"
  version="1.0"
  initialstate="one">
  <state id="start">
    <initial>
      <onentry>
        <log expr="'entering intial'" />
      </onentry>
      <transition target="other" />
    </initial>
    <state id="one" />
    <state id="other" />
  </state>
</scxml>

> spec and semantics of initialstate attribute not clear for external state
> -------------------------------------------------------------------------
>
>                 Key: SCXML-38
>                 URL: https://issues.apache.org/jira/browse/SCXML-38
>             Project: Commons SCXML
>          Issue Type: Bug
>    Affects Versions: 0.6
>         Environment: Win XP, Java 5, Eclipse 3.2, JUnit 4
>            Reporter: Wolfgang Frech
>            Priority: Minor
>
> The WD-SCXML is not fully consistent if the initialstate attribute is required for an external state, that is a state that has a src attribute pointing to a file containing its content.
> The attribute details (WD 3.1.1) define the initialstate attribute as required, without any exception for external states.
> The example Test2Sub1.scxml (WD F.1) does not have a initialstate attribute.
> If this is only a minor omission in the example, the real issue is: how does an initialstate attribute affect the behavior of the state chart?
> So far this would be only an issue with the WD.
> The commons SCXML implementation decided to treat the initialstate attribute as required.
> Demonstration code follows.
> The issue with the commons implementation is:
> It is not clear which (state) id can be given in the initialstate attribute of an external state SCXML file and what this means.
> The id of the external state itself is not accepted. See second demonstration code.
> Demo - initialstate required:
> ----
> 	@Test
> 	public void externalStateWithoutInitialstate() throws FileNotFoundException,
> 			IOException, SAXException, ModelException {
> 		final URL definition = getClass().getClassLoader().getResource(
> 				"externalStateWithoutInitialstate-main.scxml");
> 		try {
> 			SCXMLDigester.digest(definition, new SimpleErrorHandler());
> 			fail();
> 		} catch (ModelException e) {
> 			assertEquals(
> 					"Initial state null or not a descendant of state with ID \"start\"",
> 					e.getMessage());
> 		}
> 	}
> ----
> main scxml
> ----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0"
>   initialstate="start">
>   <state id="start" src="externalStateWithoutInitialstate-external.scxml"/>
> </scxml>
> ----
> included scxml 
> note: no initalstate
> ----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0">
>   <state id="start" />
> </scxml>
> Demo - with initialstate pointing to external state
> -----
> 	@Test
> 	public void externalStateWithInitialstate() throws FileNotFoundException,
> 			IOException, SAXException, ModelException {
> 		final URL definition = getClass().getClassLoader().getResource(
> 				"externalStateWithInitialstate-main.scxml");
> 		try {
> 			SCXMLDigester.digest(definition, new SimpleErrorHandler());
> 			fail();
> 		} catch (ModelException e) {
> 			assertEquals(
> 					"Initial state null or not a descendant of state with ID \"start\"",
> 					e.getMessage());
> 		}
> 	}
> -----
> main scxml
> -----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0"
>   initialstate="start">
>   <state id="start" src="externalStateWithInitialstate-external.scxml"/>
> </scxml>
> ----
> included scxml
> note: with initialstate
> ----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0"
>   initialstate="start">
>   <state id="start">
>     <onentry>
>       <log expr="'now in state start'" />
>     </onentry>
>   </state>
> </scxml>
> ----

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (SCXML-38) spec and semantics of initialstate attribute not clear for external state

Posted by "Wolfgang Frech (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SCXML-38?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12472556 ] 

Wolfgang Frech commented on SCXML-38:
-------------------------------------

ad a) I posted the issue to the W3C voice mailing list.
The question to the SCXML commons team remains: what did you implement?  

Quoting from the message to the mailing list:
---
So the real question is: what exactly is the format of the external file referenced by a src attribute?

It could be one of the following

a) a complete SCXML document, with scxml element as root, and exactly one state element, that is identical to the state element in the main SCXML document, and without initialstate attribute.
This would follow the example.

b) as a), but with an initialstate attribute pointing to its one and only state.
This would meet the definition of the scxml element

c) an fragment of a SCXML document, without scxml  root element, but with exactly one state element as root.
This would avoid the question if initialstate is required.

d) a fragement with the content of the state element, that is an XML fragment with a list of elements, not with a single root.
This would _not_: follow the example, and it would be hard to edit with an XML editor.
---

> spec and semantics of initialstate attribute not clear for external state
> -------------------------------------------------------------------------
>
>                 Key: SCXML-38
>                 URL: https://issues.apache.org/jira/browse/SCXML-38
>             Project: Commons SCXML
>          Issue Type: Bug
>    Affects Versions: 0.6
>         Environment: Win XP, Java 5, Eclipse 3.2, JUnit 4
>            Reporter: Wolfgang Frech
>            Priority: Minor
>
> The WD-SCXML is not fully consistent if the initialstate attribute is required for an external state, that is a state that has a src attribute pointing to a file containing its content.
> The attribute details (WD 3.1.1) define the initialstate attribute as required, without any exception for external states.
> The example Test2Sub1.scxml (WD F.1) does not have a initialstate attribute.
> If this is only a minor omission in the example, the real issue is: how does an initialstate attribute affect the behavior of the state chart?
> So far this would be only an issue with the WD.
> The commons SCXML implementation decided to treat the initialstate attribute as required.
> Demonstration code follows.
> The issue with the commons implementation is:
> It is not clear which (state) id can be given in the initialstate attribute of an external state SCXML file and what this means.
> The id of the external state itself is not accepted. See second demonstration code.
> Demo - initialstate required:
> ----
> 	@Test
> 	public void externalStateWithoutInitialstate() throws FileNotFoundException,
> 			IOException, SAXException, ModelException {
> 		final URL definition = getClass().getClassLoader().getResource(
> 				"externalStateWithoutInitialstate-main.scxml");
> 		try {
> 			SCXMLDigester.digest(definition, new SimpleErrorHandler());
> 			fail();
> 		} catch (ModelException e) {
> 			assertEquals(
> 					"Initial state null or not a descendant of state with ID \"start\"",
> 					e.getMessage());
> 		}
> 	}
> ----
> main scxml
> ----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0"
>   initialstate="start">
>   <state id="start" src="externalStateWithoutInitialstate-external.scxml"/>
> </scxml>
> ----
> included scxml 
> note: no initalstate
> ----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0">
>   <state id="start" />
> </scxml>
> Demo - with initialstate pointing to external state
> -----
> 	@Test
> 	public void externalStateWithInitialstate() throws FileNotFoundException,
> 			IOException, SAXException, ModelException {
> 		final URL definition = getClass().getClassLoader().getResource(
> 				"externalStateWithInitialstate-main.scxml");
> 		try {
> 			SCXMLDigester.digest(definition, new SimpleErrorHandler());
> 			fail();
> 		} catch (ModelException e) {
> 			assertEquals(
> 					"Initial state null or not a descendant of state with ID \"start\"",
> 					e.getMessage());
> 		}
> 	}
> -----
> main scxml
> -----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0"
>   initialstate="start">
>   <state id="start" src="externalStateWithInitialstate-external.scxml"/>
> </scxml>
> ----
> included scxml
> note: with initialstate
> ----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0"
>   initialstate="start">
>   <state id="start">
>     <onentry>
>       <log expr="'now in state start'" />
>     </onentry>
>   </state>
> </scxml>
> ----

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (SCXML-38) spec and semantics of initialstate attribute not clear for external state

Posted by "Wolfgang Frech (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SCXML-38?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12472343 ] 

Wolfgang Frech commented on SCXML-38:
-------------------------------------

continued ....

finally, this is accepted:
----
<?xml version="1.0"?>
<scxml
  xmlns="http://www.w3.org/2005/07/scxml"
  version="1.0"
  initialstate="one">
  <state id="start">
    <initial>
      <transition target="one" />
    </initial>
    <state id="one">
      <onentry>
        <log expr="'now in state one'" />
      </onentry>
    </state>
  </state>
</scxml>
----


By the way, an empty initial element, that is without a transition, leads to a NullPointerException in the ModelUpdater.

So we finally came up with a file in which we have two ways to specify the initial state at once.
What if they contradict.  Lets see...



> spec and semantics of initialstate attribute not clear for external state
> -------------------------------------------------------------------------
>
>                 Key: SCXML-38
>                 URL: https://issues.apache.org/jira/browse/SCXML-38
>             Project: Commons SCXML
>          Issue Type: Bug
>    Affects Versions: 0.6
>         Environment: Win XP, Java 5, Eclipse 3.2, JUnit 4
>            Reporter: Wolfgang Frech
>            Priority: Minor
>
> The WD-SCXML is not fully consistent if the initialstate attribute is required for an external state, that is a state that has a src attribute pointing to a file containing its content.
> The attribute details (WD 3.1.1) define the initialstate attribute as required, without any exception for external states.
> The example Test2Sub1.scxml (WD F.1) does not have a initialstate attribute.
> If this is only a minor omission in the example, the real issue is: how does an initialstate attribute affect the behavior of the state chart?
> So far this would be only an issue with the WD.
> The commons SCXML implementation decided to treat the initialstate attribute as required.
> Demonstration code follows.
> The issue with the commons implementation is:
> It is not clear which (state) id can be given in the initialstate attribute of an external state SCXML file and what this means.
> The id of the external state itself is not accepted. See second demonstration code.
> Demo - initialstate required:
> ----
> 	@Test
> 	public void externalStateWithoutInitialstate() throws FileNotFoundException,
> 			IOException, SAXException, ModelException {
> 		final URL definition = getClass().getClassLoader().getResource(
> 				"externalStateWithoutInitialstate-main.scxml");
> 		try {
> 			SCXMLDigester.digest(definition, new SimpleErrorHandler());
> 			fail();
> 		} catch (ModelException e) {
> 			assertEquals(
> 					"Initial state null or not a descendant of state with ID \"start\"",
> 					e.getMessage());
> 		}
> 	}
> ----
> main scxml
> ----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0"
>   initialstate="start">
>   <state id="start" src="externalStateWithoutInitialstate-external.scxml"/>
> </scxml>
> ----
> included scxml 
> note: no initalstate
> ----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0">
>   <state id="start" />
> </scxml>
> Demo - with initialstate pointing to external state
> -----
> 	@Test
> 	public void externalStateWithInitialstate() throws FileNotFoundException,
> 			IOException, SAXException, ModelException {
> 		final URL definition = getClass().getClassLoader().getResource(
> 				"externalStateWithInitialstate-main.scxml");
> 		try {
> 			SCXMLDigester.digest(definition, new SimpleErrorHandler());
> 			fail();
> 		} catch (ModelException e) {
> 			assertEquals(
> 					"Initial state null or not a descendant of state with ID \"start\"",
> 					e.getMessage());
> 		}
> 	}
> -----
> main scxml
> -----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0"
>   initialstate="start">
>   <state id="start" src="externalStateWithInitialstate-external.scxml"/>
> </scxml>
> ----
> included scxml
> note: with initialstate
> ----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0"
>   initialstate="start">
>   <state id="start">
>     <onentry>
>       <log expr="'now in state start'" />
>     </onentry>
>   </state>
> </scxml>
> ----

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Resolved: (SCXML-38) spec and semantics of initialstate attribute not clear for external state

Posted by "Rahul Akolkar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SCXML-38?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rahul Akolkar resolved SCXML-38.
--------------------------------

    Resolution: Won't Fix

Two components to this as the title suggests:

a) Any inconsistencies found in the spec document - While we don't deal with those here, it'll be great if you can report them to the W3C WG.

b) The test case you have posted -- I suspect the majority of problems you are running into with this test case have to do with the fact that once the external SCXML document is pulled in, the state IDs are no longer unique ("start" is present in both). Ofcourse, there are scenarios where you may want to pull in the same document couple of times in the state machine whereby you have to employ some state templating techniques (the src attribute can point to a URI generating dynamic content). I seem to remember someone writing up a wiki page on the Commons SCXML wiki for this. Please check it out or look into the mailing list archives for discussions on this. Also, please feel free to ask on the user list.


> spec and semantics of initialstate attribute not clear for external state
> -------------------------------------------------------------------------
>
>                 Key: SCXML-38
>                 URL: https://issues.apache.org/jira/browse/SCXML-38
>             Project: Commons SCXML
>          Issue Type: Bug
>    Affects Versions: 0.6
>         Environment: Win XP, Java 5, Eclipse 3.2, JUnit 4
>            Reporter: Wolfgang Frech
>            Priority: Minor
>
> The WD-SCXML is not fully consistent if the initialstate attribute is required for an external state, that is a state that has a src attribute pointing to a file containing its content.
> The attribute details (WD 3.1.1) define the initialstate attribute as required, without any exception for external states.
> The example Test2Sub1.scxml (WD F.1) does not have a initialstate attribute.
> If this is only a minor omission in the example, the real issue is: how does an initialstate attribute affect the behavior of the state chart?
> So far this would be only an issue with the WD.
> The commons SCXML implementation decided to treat the initialstate attribute as required.
> Demonstration code follows.
> The issue with the commons implementation is:
> It is not clear which (state) id can be given in the initialstate attribute of an external state SCXML file and what this means.
> The id of the external state itself is not accepted. See second demonstration code.
> Demo - initialstate required:
> ----
> 	@Test
> 	public void externalStateWithoutInitialstate() throws FileNotFoundException,
> 			IOException, SAXException, ModelException {
> 		final URL definition = getClass().getClassLoader().getResource(
> 				"externalStateWithoutInitialstate-main.scxml");
> 		try {
> 			SCXMLDigester.digest(definition, new SimpleErrorHandler());
> 			fail();
> 		} catch (ModelException e) {
> 			assertEquals(
> 					"Initial state null or not a descendant of state with ID \"start\"",
> 					e.getMessage());
> 		}
> 	}
> ----
> main scxml
> ----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0"
>   initialstate="start">
>   <state id="start" src="externalStateWithoutInitialstate-external.scxml"/>
> </scxml>
> ----
> included scxml 
> note: no initalstate
> ----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0">
>   <state id="start" />
> </scxml>
> Demo - with initialstate pointing to external state
> -----
> 	@Test
> 	public void externalStateWithInitialstate() throws FileNotFoundException,
> 			IOException, SAXException, ModelException {
> 		final URL definition = getClass().getClassLoader().getResource(
> 				"externalStateWithInitialstate-main.scxml");
> 		try {
> 			SCXMLDigester.digest(definition, new SimpleErrorHandler());
> 			fail();
> 		} catch (ModelException e) {
> 			assertEquals(
> 					"Initial state null or not a descendant of state with ID \"start\"",
> 					e.getMessage());
> 		}
> 	}
> -----
> main scxml
> -----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0"
>   initialstate="start">
>   <state id="start" src="externalStateWithInitialstate-external.scxml"/>
> </scxml>
> ----
> included scxml
> note: with initialstate
> ----
> <?xml version="1.0"?>
> <scxml
>   xmlns="http://www.w3.org/2005/07/scxml"
>   version="1.0"
>   initialstate="start">
>   <state id="start">
>     <onentry>
>       <log expr="'now in state start'" />
>     </onentry>
>   </state>
> </scxml>
> ----

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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