You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Ingmar Kliche (JIRA)" <ji...@apache.org> on 2008/11/08 12:30:44 UTC

[jira] Created: (SCXML-88) SCXMLSerializer does not serialize custom namespace declarations

SCXMLSerializer does not serialize custom namespace declarations
----------------------------------------------------------------

                 Key: SCXML-88
                 URL: https://issues.apache.org/jira/browse/SCXML-88
             Project: Commons SCXML
          Issue Type: Bug
    Affects Versions: 0.8
            Reporter: Ingmar Kliche


The SCXMLSerializer writes the scxml namespace as the default namespace to the <scxml> root tag and adds a "cs" ("commons-scxml") namespace by default.

But it does not take into account that the original scxml document might contain other namespace declarations, e.g. on child tags:

<?xml version="1.0" encoding="UTF-8"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:cs="http://commons.apache.org/scxml" version="1.0" initial="S1">
 <state id="S1">
  <!-- some E4X like condition using XML namespaces -->
  <!-- redefine default namespace to "foo" and use explicit namespace prefix for scxml:transition tag -->
  <scxml:transition event="foo" cond="a.b.bar::c.* == 3" target="S2" xmlns="foo" xmlns:scxml="http://www.w3.org/2005/07/scxml" xmlns:bar="bar">
  </transition>
 </state>
 <state id="S2" final="true">
 </state>
</scxml>

The above SCXML document is parsed properly and namespaces are forwarded to the executor (i.e. it works correct).  But if it comes to serialization the namespaces are not serialized properly.

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


[jira] Commented: (SCXML-88) SCXMLSerializer does not serialize custom namespace declarations

Posted by "Ingmar Kliche (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SCXML-88?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12646500#action_12646500 ] 

Ingmar Kliche commented on SCXML-88:
------------------------------------

And why not retaining namespace prefixes for all elements? This shouldn't be too much overhead.

> SCXMLSerializer does not serialize custom namespace declarations
> ----------------------------------------------------------------
>
>                 Key: SCXML-88
>                 URL: https://issues.apache.org/jira/browse/SCXML-88
>             Project: Commons SCXML
>          Issue Type: Bug
>    Affects Versions: 0.8
>            Reporter: Ingmar Kliche
>             Fix For: 0.9
>
>         Attachments: NamespacesInTransition_testcase.patch
>
>
> The SCXMLSerializer writes the scxml namespace as the default namespace to the <scxml> root tag and adds a "cs" ("commons-scxml") namespace by default.
> But it does not take into account that the original scxml document might contain other namespace declarations, e.g. on child tags:
> <?xml version="1.0" encoding="UTF-8"?>
> <scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:cs="http://commons.apache.org/scxml" version="1.0" initial="S1">
>  <state id="S1">
>   <!-- some E4X like condition using XML namespaces -->
>   <!-- redefine default namespace to "foo" and use explicit namespace prefix for scxml:transition tag -->
>   <scxml:transition event="foo" cond="a.b.bar::c.* == 3" target="S2" xmlns="foo" xmlns:scxml="http://www.w3.org/2005/07/scxml" xmlns:bar="bar">
>   </transition>
>  </state>
>  <state id="S2" final="true">
>  </state>
> </scxml>
> The above SCXML document is parsed properly and namespaces are forwarded to the executor (i.e. it works correct).  But if it comes to serialization the namespaces are not serialized properly.

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


[jira] Commented: (SCXML-88) SCXMLSerializer does not serialize custom namespace declarations

Posted by "Rahul Akolkar (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SCXML-88?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12646579#action_12646579 ] 

Rahul Akolkar commented on SCXML-88:
------------------------------------

Could be quite significant actually. Maps have high overhead, especially when they are close to empty which these guys are (a map would perhaps be a logical choice, and thats what the digester gives us so its also least effort). I'm leaning towards making some recommendations if folks want to use the serializer. I won't be able to look at this immediately, but if you (or anyone else) is able to whip up a patch, it can always be sooner. Thanks,


> SCXMLSerializer does not serialize custom namespace declarations
> ----------------------------------------------------------------
>
>                 Key: SCXML-88
>                 URL: https://issues.apache.org/jira/browse/SCXML-88
>             Project: Commons SCXML
>          Issue Type: Bug
>    Affects Versions: 0.8
>            Reporter: Ingmar Kliche
>             Fix For: 0.9
>
>         Attachments: NamespacesInTransition_testcase.patch
>
>
> The SCXMLSerializer writes the scxml namespace as the default namespace to the <scxml> root tag and adds a "cs" ("commons-scxml") namespace by default.
> But it does not take into account that the original scxml document might contain other namespace declarations, e.g. on child tags:
> <?xml version="1.0" encoding="UTF-8"?>
> <scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:cs="http://commons.apache.org/scxml" version="1.0" initial="S1">
>  <state id="S1">
>   <!-- some E4X like condition using XML namespaces -->
>   <!-- redefine default namespace to "foo" and use explicit namespace prefix for scxml:transition tag -->
>   <scxml:transition event="foo" cond="a.b.bar::c.* == 3" target="S2" xmlns="foo" xmlns:scxml="http://www.w3.org/2005/07/scxml" xmlns:bar="bar">
>   </transition>
>  </state>
>  <state id="S2" final="true">
>  </state>
> </scxml>
> The above SCXML document is parsed properly and namespaces are forwarded to the executor (i.e. it works correct).  But if it comes to serialization the namespaces are not serialized properly.

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


[jira] Updated: (SCXML-88) SCXMLSerializer does not serialize custom namespace declarations

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

Ingmar Kliche updated SCXML-88:
-------------------------------

    Attachment: NamespacesInTransition_testcase.patch

JUnit Testcase for using namespaces in transitions

> SCXMLSerializer does not serialize custom namespace declarations
> ----------------------------------------------------------------
>
>                 Key: SCXML-88
>                 URL: https://issues.apache.org/jira/browse/SCXML-88
>             Project: Commons SCXML
>          Issue Type: Bug
>    Affects Versions: 0.8
>            Reporter: Ingmar Kliche
>         Attachments: NamespacesInTransition_testcase.patch
>
>
> The SCXMLSerializer writes the scxml namespace as the default namespace to the <scxml> root tag and adds a "cs" ("commons-scxml") namespace by default.
> But it does not take into account that the original scxml document might contain other namespace declarations, e.g. on child tags:
> <?xml version="1.0" encoding="UTF-8"?>
> <scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:cs="http://commons.apache.org/scxml" version="1.0" initial="S1">
>  <state id="S1">
>   <!-- some E4X like condition using XML namespaces -->
>   <!-- redefine default namespace to "foo" and use explicit namespace prefix for scxml:transition tag -->
>   <scxml:transition event="foo" cond="a.b.bar::c.* == 3" target="S2" xmlns="foo" xmlns:scxml="http://www.w3.org/2005/07/scxml" xmlns:bar="bar">
>   </transition>
>  </state>
>  <state id="S2" final="true">
>  </state>
> </scxml>
> The above SCXML document is parsed properly and namespaces are forwarded to the executor (i.e. it works correct).  But if it comes to serialization the namespaces are not serialized properly.

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


[jira] Resolved: (SCXML-88) SCXMLSerializer does not serialize custom namespace declarations

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

Rahul Akolkar resolved SCXML-88.
--------------------------------

    Resolution: Fixed

I'm marking this as fixed since the situation has now improved in the sense that it is possible to get the serializer to write out the custom declarations, but only within certain limitations.

Those limitations are now clearly specified in the class Javadoc, which I have deployed to the site. See:

  http://commons.apache.org/scxml/apidocs/org/apache/commons/scxml/io/SCXMLSerializer.html

In order to not rely on the link above, I'll reproduce the limitations below:

----
NOTE: This serializer makes the following assumptions about the original SCXML document(s) parsed to create the object model: 
 * The default document namespace is the SCXML namespace: http://www.w3.org/2005/07/scxml 
 * The Commons SCXML namespace ( http://commons.apache.org/scxml ), if needed, uses the "cs" prefix 
 * All namespace prefixes needed throughout the document are declared on the document root element (<scxml>) 
----

Your test case will still not work, unless you move the namespace declarations to the root <scxml> element.

Ofcourse, ideally it should be possible to accomodate declarations anywhere in the document, but I contend that the focus of this library is the execution of state machines rather than the serialization of its object model. Furthermore, even though I do not intend to spend more time on this at the moment given that a workable solution is available within those limitations, if a patch were to become available that serialized the namespace declarations for transitions, actions etc. and included test cases to demonstrate correctness, we can revisit this.


> SCXMLSerializer does not serialize custom namespace declarations
> ----------------------------------------------------------------
>
>                 Key: SCXML-88
>                 URL: https://issues.apache.org/jira/browse/SCXML-88
>             Project: Commons SCXML
>          Issue Type: Bug
>    Affects Versions: 0.8
>            Reporter: Ingmar Kliche
>             Fix For: 0.9
>
>         Attachments: NamespacesInTransition_testcase.patch
>
>
> The SCXMLSerializer writes the scxml namespace as the default namespace to the <scxml> root tag and adds a "cs" ("commons-scxml") namespace by default.
> But it does not take into account that the original scxml document might contain other namespace declarations, e.g. on child tags:
> <?xml version="1.0" encoding="UTF-8"?>
> <scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:cs="http://commons.apache.org/scxml" version="1.0" initial="S1">
>  <state id="S1">
>   <!-- some E4X like condition using XML namespaces -->
>   <!-- redefine default namespace to "foo" and use explicit namespace prefix for scxml:transition tag -->
>   <scxml:transition event="foo" cond="a.b.bar::c.* == 3" target="S2" xmlns="foo" xmlns:scxml="http://www.w3.org/2005/07/scxml" xmlns:bar="bar">
>   </transition>
>  </state>
>  <state id="S2" final="true">
>  </state>
> </scxml>
> The above SCXML document is parsed properly and namespaces are forwarded to the executor (i.e. it works correct).  But if it comes to serialization the namespaces are not serialized properly.

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


[jira] Updated: (SCXML-88) SCXMLSerializer does not serialize custom namespace declarations

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

Rahul Akolkar updated SCXML-88:
-------------------------------

    Fix Version/s: 0.9

Setting fix version to v0.9.

This is going to be interesting, since we don't retain namespace prefixes for all elements (only executable content, i.e. actions). I suspect we may have to make some recommendations (or, lay some restrictions, depending how one looks at it :-) about this.


> SCXMLSerializer does not serialize custom namespace declarations
> ----------------------------------------------------------------
>
>                 Key: SCXML-88
>                 URL: https://issues.apache.org/jira/browse/SCXML-88
>             Project: Commons SCXML
>          Issue Type: Bug
>    Affects Versions: 0.8
>            Reporter: Ingmar Kliche
>             Fix For: 0.9
>
>         Attachments: NamespacesInTransition_testcase.patch
>
>
> The SCXMLSerializer writes the scxml namespace as the default namespace to the <scxml> root tag and adds a "cs" ("commons-scxml") namespace by default.
> But it does not take into account that the original scxml document might contain other namespace declarations, e.g. on child tags:
> <?xml version="1.0" encoding="UTF-8"?>
> <scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:cs="http://commons.apache.org/scxml" version="1.0" initial="S1">
>  <state id="S1">
>   <!-- some E4X like condition using XML namespaces -->
>   <!-- redefine default namespace to "foo" and use explicit namespace prefix for scxml:transition tag -->
>   <scxml:transition event="foo" cond="a.b.bar::c.* == 3" target="S2" xmlns="foo" xmlns:scxml="http://www.w3.org/2005/07/scxml" xmlns:bar="bar">
>   </transition>
>  </state>
>  <state id="S2" final="true">
>  </state>
> </scxml>
> The above SCXML document is parsed properly and namespaces are forwarded to the executor (i.e. it works correct).  But if it comes to serialization the namespaces are not serialized properly.

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