commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r808257 - in /commons/proper/scxml/branches/J6/extras: ./ README.txt xmi2scxml.xsl
Date Thu, 27 Aug 2009 02:46:04 GMT
Author: rahul
Date: Thu Aug 27 02:46:03 2009
New Revision: 808257

URL: http://svn.apache.org/viewvc?rev=808257&view=rev
Log:
A simple (and yet incomplete) stylesheet that converts XMI documents such as those from Eclipse
MDT UML2 Tools models to corresponding SCXML documents.

Added:
    commons/proper/scxml/branches/J6/extras/
    commons/proper/scxml/branches/J6/extras/README.txt   (with props)
    commons/proper/scxml/branches/J6/extras/xmi2scxml.xsl   (with props)

Added: commons/proper/scxml/branches/J6/extras/README.txt
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/extras/README.txt?rev=808257&view=auto
==============================================================================
--- commons/proper/scxml/branches/J6/extras/README.txt (added)
+++ commons/proper/scxml/branches/J6/extras/README.txt Thu Aug 27 02:46:03 2009
@@ -0,0 +1,31 @@
+<!--
+ * 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.
+-->
+$Id$
+
+                          Commons SCXML Extras
+
+(1) xmi2scxml.xsl
+
+    A simple and yet incomplete stylesheet that converts from XMI format to
+    multiple SCXML documents.
+
+    Tried with Eclipse MDT UML2 Tools 0.9.0 under Incubation.
+
+    Example usage:
+
+      java -jar saxon9.jar -t -s:statemachines.uml -xsl:xmi2scxml.xsl -o:conversionsummary.xml
+

Propchange: commons/proper/scxml/branches/J6/extras/README.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/scxml/branches/J6/extras/README.txt
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: commons/proper/scxml/branches/J6/extras/xmi2scxml.xsl
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/extras/xmi2scxml.xsl?rev=808257&view=auto
==============================================================================
--- commons/proper/scxml/branches/J6/extras/xmi2scxml.xsl (added)
+++ commons/proper/scxml/branches/J6/extras/xmi2scxml.xsl Thu Aug 27 02:46:03 2009
@@ -0,0 +1,165 @@
+<?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.
+-->
+<xsl:stylesheet version="2.0"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
+  xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" xmlns:scxml="http://www.w3.org/2005/07/scxml">
+
+  <xsl:output method="xml" indent="yes" encoding="UTF-8" />
+
+  <xsl:template match="uml:Package">
+<xsl:comment>
+  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.
+</xsl:comment><xsl:text>&#xA;</xsl:text>
+<xsl:comment>
+  This file was generated by a stylesheet from the Apache Commons SCXML
+  project: http://commons.apache.org/scxml
+</xsl:comment><xsl:text>&#xA;</xsl:text>
+    <scxmlfiles>
+      <xsl:apply-templates select="packagedElement" />
+    </scxmlfiles><xsl:text>&#xA;</xsl:text>
+  </xsl:template>
+
+  <xsl:template match="packagedElement">
+    <xsl:variable name="type" select="@xmi:type" />
+    <xsl:variable name="name" select="@name" />
+    <xsl:variable name="filename" select="concat($name,'.xml')" />
+    <file uml2name="{$name}" scxmlfile="{$filename}" />
+    <xsl:result-document href="{$filename}" method="xml">
+<xsl:comment>
+  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.
+</xsl:comment><xsl:text>&#xA;</xsl:text>
+<xsl:comment>
+  This file was generated by a stylesheet from the Apache Commons SCXML
+  project: http://commons.apache.org/scxml
+</xsl:comment><xsl:text>&#xA;</xsl:text>
+      <xsl:choose>
+        <xsl:when test="count(child::region) &gt; 1">
+          <scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0"
+            initial="__root">
+            <parallel xmlns="http://www.w3.org/2005/07/scxml" id="__root">
+              <xsl:apply-templates select="region">
+                <xsl:with-param name="orth" select="true()"/>
+              </xsl:apply-templates>
+            </parallel>
+          </scxml><xsl:text>&#xA;</xsl:text>
+        </xsl:when>
+        <xsl:otherwise>
+          <scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0"
+            initial="{region/subvertex[@xmi:type='uml:Pseudostate'][empty(@kind)]/@xmi:id}">
+            <xsl:apply-templates select="region">
+              <xsl:with-param name="orth" select="false()"/>
+            </xsl:apply-templates>
+          </scxml><xsl:text>&#xA;</xsl:text>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:result-document>
+  </xsl:template>
+
+  <xsl:template match="region">
+    <xsl:param name="orth" />
+    <xsl:choose>
+      <xsl:when test="$orth">
+        <state xmlns="http://www.w3.org/2005/07/scxml" id="{concat('__region',position())}"
initial="{subvertex[@xmi:type='uml:Pseudostate'][empty(@kind)]/@xmi:id}">
+          <xsl:apply-templates select="subvertex" />
+        </state>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates select="subvertex" />
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <xsl:template match="subvertex">
+    <xsl:variable name="type" select="@xmi:type" />
+    <xsl:variable name="xmiid" select="@xmi:id" />
+    <xsl:variable name="name" select="@name" />
+    <xsl:variable name="id" select="if (empty($name)) then $xmiid else $name" />
+    <xsl:choose>
+      <xsl:when test="$type='uml:Pseudostate'">
+        <xsl:choose>
+          <xsl:when test="@kind='deepHistory'">
+            <history xmlns="http://www.w3.org/2005/07/scxml" type="deep" id="{$id}">
+              <xsl:apply-templates select="../transition[@source=$xmiid]" />
+            </history>
+          </xsl:when>
+          <xsl:when test="@kind='shallowHistory'">
+            <history xmlns="http://www.w3.org/2005/07/scxml" type="shallow" id="{$id}">
+              <xsl:apply-templates select="../transition[@source=$xmiid]" />
+            </history>
+          </xsl:when>
+          <xsl:otherwise>
+            <state xmlns="http://www.w3.org/2005/07/scxml" id="{$id}">
+              <xsl:apply-templates select="../transition[@source=$xmiid]" />
+            </state>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:when>
+      <xsl:when test="$type='uml:State'">
+        <state xmlns="http://www.w3.org/2005/07/scxml" id="{$id}">
+          <xsl:apply-templates select="../transition[@source=$xmiid]" />
+        </state>
+      </xsl:when>
+      <xsl:when test="$type='uml:FinalState'">
+        <final xmlns="http://www.w3.org/2005/07/scxml" id="{$id}" />
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates />
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <xsl:template match="transition">
+    <xsl:variable name="target" select="@target" />
+    <xsl:variable name="tname" select="if (empty(../subvertex[@xmi:id=$target]/@name))
then ../subvertex[@xmi:id=$target]/@xmi:id else ../subvertex[@xmi:id=$target]/@name" />
+    <xsl:choose>
+      <xsl:when test="empty(@name)">
+        <transition xmlns="http://www.w3.org/2005/07/scxml" target="{$tname}" />
+      </xsl:when>
+      <xsl:otherwise>
+        <transition xmlns="http://www.w3.org/2005/07/scxml" event="{@name}" target="{$tname}"
/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+</xsl:stylesheet>

Propchange: commons/proper/scxml/branches/J6/extras/xmi2scxml.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/scxml/branches/J6/extras/xmi2scxml.xsl
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL



Mime
View raw message