Author: guixl
Date: Fri Jun 18 08:43:14 2010
New Revision: 955887

URL: http://svn.apache.org/viewvc?rev=955887&view=rev
Log:
Improve SCXML document export function, add 
subState,parallel,finalState,historyState and some other SCXML elements

Modified:
    
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/export/ScxmlExportStreamHandlerAction.java
    
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/xslt/export.xsl

Modified: 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/export/ScxmlExportStreamHandlerAction.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/export/ScxmlExportStreamHandlerAction.java?rev=955887&r1=955886&r2=955887&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/export/ScxmlExportStreamHandlerAction.java
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/export/ScxmlExportStreamHandlerAction.java
 Fri Jun 18 08:43:14 2010
@@ -75,7 +75,8 @@ public class ScxmlExportStreamHandlerAct
        }
 
        public void contentPreHandler(){
-               
streamContnet=streamContnet.replace("org.apache.commons.scxml:ServiceTemplate", 
"ServiceTemplate");
+               
streamContnet=streamContnet.replace("org.apache.commons.scxml:", 
"org.apache.commons.scxml_");
+               streamContnet=streamContnet.replace("xsi:type", "xsi_type");
        }
        public void getTargetList() {
                String regx = "targetStatus=\"\\S+\"";

Modified: 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/xslt/export.xsl
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/xslt/export.xsl?rev=955887&r1=955886&r2=955887&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/xslt/export.xsl
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/xslt/export.xsl
 Fri Jun 18 08:43:14 2010
@@ -4,14 +4,20 @@
 
 <xsl:template match="/">
                <xsl:element name="scxml">
-                       <xsl:attribute name="initial"><xsl:value-of  
select="ServiceTemplate/@initial"/></xsl:attribute>
-                       <xsl:attribute name="name"><xsl:value-of  
select="ServiceTemplate/@name"/></xsl:attribute>
+                       <xsl:attribute name="initial"><xsl:value-of  
select="org.apache.commons.scxml_ServiceTemplate/@initial"/></xsl:attribute>
+                       <xsl:attribute name="name"><xsl:value-of  
select="org.apache.commons.scxml_ServiceTemplate/@name"/></xsl:attribute>
                        <xsl:attribute name="version">1.0</xsl:attribute>
                        <xsl:attribute 
name="xmlns_attribute_url_in_xslt_file">http://www.w3.org/2005/07/scxml</xsl:attribute>
                        <xsl:apply-templates/>
                </xsl:element>
 </xsl:template>
 
+<xsl:template match="initState">
+       <xsl:element name="initial">
+               <xsl:apply-templates/>
+       </xsl:element>
+</xsl:template>
+
 <xsl:template match="stateList">
        <xsl:element name="state">
                <xsl:attribute name="id"><xsl:value-of  
select="@id"/></xsl:attribute>
@@ -19,6 +25,22 @@
        </xsl:element>
 </xsl:template>
 
+<xsl:template match="parallel">
+       <xsl:element name="parallel">
+               <xsl:if test="@id">
+                       <xsl:attribute name="id"><xsl:value-of  
select="@id"/></xsl:attribute>
+               </xsl:if>
+               <xsl:apply-templates/>
+       </xsl:element>
+</xsl:template>
+
+<xsl:template match="finalState">
+       <xsl:element name="state">
+               <xsl:attribute name="id"><xsl:value-of  
select="@id"/></xsl:attribute>
+               <xsl:apply-templates/>
+       </xsl:element>
+</xsl:template>
+
 <xsl:template match="subState">
        <xsl:element name="state">
                <xsl:attribute name="id"><xsl:value-of  
select="@id"/></xsl:attribute>
@@ -28,24 +50,120 @@
 
 <xsl:template match="onEntry">
        <xsl:element name="onEntry">
+               <xsl:apply-templates/>
        </xsl:element>
 </xsl:template>
 
 <xsl:template match="onExit">
        <xsl:element name="onExit">
+               <xsl:apply-templates/>
+       </xsl:element>
+</xsl:template>
+
+<xsl:template match="invoke">
+       <xsl:element name="invoke">
+               <xsl:if test="@type"><xsl:attribute name="type"><xsl:value-of  
select="@type"/></xsl:attribute></xsl:if>
+               <xsl:if test="@typeexpr"><xsl:attribute 
name="typeexpr"><xsl:value-of  select="@typeexpr"/></xsl:attribute></xsl:if>
+               <xsl:if test="@src"><xsl:attribute name="src"><xsl:value-of  
select="@src"/></xsl:attribute></xsl:if>
+               <xsl:if test="@srcexpr"><xsl:attribute 
name="srcexpr"><xsl:value-of  select="@srcexpr"/></xsl:attribute></xsl:if>
+               <xsl:if test="@id"><xsl:attribute name="id"><xsl:value-of  
select="@id"/></xsl:attribute></xsl:if>
+               <xsl:if test="@idlocation"><xsl:attribute 
name="idlocation"><xsl:value-of  select="@idlocation"/></xsl:attribute></xsl:if>
+               <xsl:if test="@namelist"><xsl:attribute 
name="namelist"><xsl:value-of  select="@namelist"/></xsl:attribute></xsl:if>
+               <xsl:if test="@autoforward"><xsl:attribute 
name="autoforward"><xsl:value-of  
select="@autoforward"/></xsl:attribute></xsl:if>
+               <xsl:apply-templates/>
+       </xsl:element>
+</xsl:template>
+
+<xsl:template match="historyState">
+       <xsl:element name="history">
+               <xsl:if test="@id"><xsl:attribute name="id"><xsl:value-of  
select="@id"/></xsl:attribute></xsl:if>
+               <xsl:if test="@type"><xsl:attribute name="type"><xsl:value-of  
select="@type"/></xsl:attribute></xsl:if>
+               <xsl:apply-templates/>
+       </xsl:element>
+</xsl:template>
+
+<xsl:template match="subParallel">
+       <xsl:element name="parallel">
+               <xsl:if test="@id">
+                       <xsl:attribute name="id"><xsl:value-of  
select="@id"/></xsl:attribute>
+               </xsl:if>
+               <xsl:apply-templates/>
        </xsl:element>
 </xsl:template>
 
 <xsl:template match="targetConnection">
        <xsl:element name="transition">
                <xsl:if test="@event">
-               <xsl:attribute name="event"><xsl:value-of  
select="@event"/></xsl:attribute>
+                       <xsl:attribute name="event"><xsl:value-of  
select="@event"/></xsl:attribute>
                </xsl:if>
                <xsl:if test="@cond">
-               <xsl:attribute name="cond"><xsl:value-of  
select="@cond"/></xsl:attribute>
+                       <xsl:attribute name="cond"><xsl:value-of  
select="@cond"/></xsl:attribute>
                </xsl:if>
                <xsl:attribute name="target"><xsl:value-of  
select="@target"/></xsl:attribute>
        </xsl:element>
 </xsl:template>
 
+<xsl:template match="executableContext">
+       <xsl:choose>
+       <xsl:when test="@xsi_type='org.apache.commons.scxml_Log'">
+               <xsl:element name="log">
+                       <xsl:attribute name="label"><xsl:value-of  
select="@label"/></xsl:attribute>
+                       <xsl:attribute name="expr"><xsl:value-of  
select="@expr"/></xsl:attribute>
+               </xsl:element>
+       </xsl:when>
+       <xsl:when test="@xsi_type='org.apache.commons.scxml_Raise'">
+               <xsl:element name="raise">
+                       <xsl:attribute name="event"><xsl:value-of  
select="@event"/></xsl:attribute>
+               </xsl:element>
+       </xsl:when>
+       <xsl:when test="@xsi_type='org.apache.commons.scxml_If'">
+               <xsl:element name="if">
+                       <xsl:attribute name="cond"><xsl:value-of  
select="@cond"/></xsl:attribute>
+                       <xsl:apply-templates/>
+               </xsl:element>
+       </xsl:when>
+       <xsl:when test="@xsi_type='org.apache.commons.scxml_Assign'">
+               <xsl:element name="assign">
+                       <xsl:attribute name="location"><xsl:value-of  
select="@location"/></xsl:attribute>
+                       <xsl:attribute name="expr"><xsl:value-of  
select="@expr"/></xsl:attribute>
+               </xsl:element>
+       </xsl:when>
+       <xsl:otherwise>
+       </xsl:otherwise>
+       </xsl:choose>
+</xsl:template>
+
+<xsl:template match="dataModel">
+       <xsl:element name="datamodel">
+               <xsl:if test="@schema">
+                       <xsl:attribute name="schema"><xsl:value-of  
select="@schema"/></xsl:attribute>
+               </xsl:if>
+               <xsl:apply-templates/>
+       </xsl:element>
+</xsl:template>
+
+<xsl:template match="data">
+       <xsl:element name="data">
+               <xsl:attribute name="id"><xsl:value-of  
select="@id"/></xsl:attribute>
+               <xsl:if test="@src">
+                       <xsl:attribute name="src"><xsl:value-of  
select="@src"/></xsl:attribute>
+               </xsl:if>
+               <xsl:if test="@expr">
+                       <xsl:attribute name="expr"><xsl:value-of  
select="@expr"/></xsl:attribute>
+               </xsl:if>
+               <xsl:apply-templates/>
+       </xsl:element>
+</xsl:template>
+
+<xsl:template match="content">
+       <xsl:element name="content">
+               <xsl:apply-templates/>
+       </xsl:element>
+</xsl:template>
+
+<xsl:template match="script">
+       <xsl:element name="script">
+       </xsl:element>
+</xsl:template>
+
 </xsl:stylesheet>
\ No newline at end of file


Reply via email to