Author: jbeard
Date: Thu Mar 17 16:19:25 2011
New Revision: 1082565

URL: http://svn.apache.org/viewvc?rev=1082565&view=rev
Log:
Moved out ugly code that generates transitions table.

Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/util/scxml-to-dot.xsl

Modified: 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/util/scxml-to-dot.xsl
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/util/scxml-to-dot.xsl?rev=1082565&r1=1082564&r2=1082565&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/util/scxml-to-dot.xsl 
(original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/util/scxml-to-dot.xsl Thu 
Mar 17 16:19:25 2011
@@ -29,6 +29,25 @@ a document in the graphviz dot syntax.
 
        <variable name="states" select="//s:state | //s:parallel"/>
 
+       <template name="htmlTransitionLabel">
+               <param name="transitions"/>
+
+               <text>label=&lt;&lt;TABLE&gt;</text>
+               <for-each select="$transitions">
+                       <text>&lt;TR&gt;</text>
+                               <text>&lt;TD&gt;</text>
+                               <value-of select="@event"/>
+                               <text>&lt;/TD&gt;</text>
+                               <text>&lt;TD&gt;</text>
+                               <call-template name="attribute-value">
+                                       <with-param name="text" select="@cond"/>
+                               </call-template>
+                               <text>&lt;/TD&gt;</text>
+                       <text>&lt;/TR&gt;</text>
+               </for-each>
+               <text>&lt;/TABLE&gt;&gt;</text>
+       </template>
+
        <template match="/">
                digraph G {
                        <apply-templates select="*[not(self::s:transition)]"/>
@@ -63,7 +82,13 @@ a document in the graphviz dot syntax.
                        <variable name="static_reactions" 
select="s:transition[not(@target)]"/>
 
                        <if test="$static_reactions">
-                               <value-of select="@id"/>_static_reactions 
[label=&lt;&lt;TABLE&gt;<for-each 
select="$static_reactions">&lt;TR&gt;&lt;TD&gt;<value-of 
select="@event"/>&lt;/TD&gt;&lt;TD&gt;<call-template 
name="attribute-value"><with-param name="text" 
select="@cond"/></call-template>&lt;/TD&gt;&lt;/TR&gt;</for-each>&lt;/TABLE&gt;&gt;];
+                               <value-of select="@id"/>
+                               <text>_static_reactions </text>
+                               <text>[ </text>
+                               <call-template name="htmlTransitionLabel">
+                                       <with-param name="transitions" 
select="$static_reactions"/>
+                               </call-template>
+                               <text> ];</text>
                        </if>
                }
        </template>
@@ -123,8 +148,9 @@ a document in the graphviz dot syntax.
                        <choose>
                                <when test="count($transitions) > 1">
                                        <!-- multiple transitions. use html 
label -->
-                                       <!-- FIXME: this code is ugly and 
repeated twice -->
-                                       label=&lt;&lt;TABLE&gt;<for-each 
select="$transitions">&lt;TR&gt;&lt;TD&gt;<value-of 
select="@event"/>&lt;/TD&gt;&lt;TD&gt;<call-template 
name="attribute-value"><with-param name="text" 
select="@cond"/></call-template>&lt;/TD&gt;&lt;/TR&gt;</for-each>&lt;/TABLE&gt;&gt;
+                                       <call-template 
name="htmlTransitionLabel">
+                                               <with-param name="transitions" 
select="$transitions"/>
+                                       </call-template>
                                </when>
                                <otherwise>
                                        <variable name="firstTransition" 
select="$transitions[1]"/>


Reply via email to