Author: jbeard
Date: Thu Mar 17 16:20:10 2011
New Revision: 1082569

URL: http://svn.apache.org/viewvc?rev=1082569&view=rev
Log:
Added ability to parameterize depth of states generated.

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=1082569&r1=1082568&r2=1082569&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:20:10 2011
@@ -25,8 +25,11 @@ a document in the graphviz dot syntax.
        xmlns:s="http://www.w3.org/2005/07/scxml";
        version="1.0">
        <import href="xml-to-string.xsl"/>
+
        <output method="text"/>
 
+       <param name="maxDepth" select="9999"/>
+
        <variable name="states" select="//s:state | //s:parallel"/>
 
        <template name="htmlTransitionLabel">
@@ -60,13 +63,14 @@ a document in the graphviz dot syntax.
        </template>
 
        <template match="/">
+
                digraph G {
                        <apply-templates select="*[not(self::s:transition)]"/>
 
-                       <for-each select="$states">
+                       <for-each select="$states[count(ancestor::*) &lt; 
$maxDepth]">
                                <variable name="fromState" select="."/>
 
-                               <for-each select="$states">
+                               <for-each select="$states[count(ancestor::*) 
&lt; $maxDepth]">
                                        <variable name="toState" select="."/>
                                        
                                        <variable name="transitions" 
select="$fromState/s:transition[@target=$toState/@id]"/>
@@ -84,49 +88,63 @@ a document in the graphviz dot syntax.
        </template>
 
        <template match="s:scxml | s:state[.//s:state] | s:parallel">
-               subgraph cluster_<value-of select="@id"/> {
-                       <choose>
-                               <when test="self::s:scxml">
-                                       color="blue";
-                               </when>
-                               <when test="../@initial = @id">
-                                       color="green";
-                               </when>
-                               <otherwise>
-                                       color="black";
-                               </otherwise>
-                       </choose>
+               <choose>
+                       <when test="count(ancestor::*) &lt; $maxDepth">
+                               subgraph cluster_<value-of select="@id"/> {
+                                       <choose>
+                                               <when test="self::s:scxml">
+                                                       color="blue";
+                                               </when>
+                                               <when test="../@initial = @id">
+                                                       color="green";
+                                               </when>
+                                               <otherwise>
+                                                       color="black";
+                                               </otherwise>
+                                       </choose>
 
-                       
-                       <text>style="rounded,</text>
-                       <choose>
-                               <when test="../self::s:parallel">
-                                       <text>dashed</text>
-                               </when>
-                               <otherwise>
-                                       <text>solid</text>
-                               </otherwise>
-                       </choose>
-                       <text>";</text>
+                                       
+                                       <text>style="rounded,</text>
+                                       <choose>
+                                               <when 
test="../self::s:parallel">
+                                                       <text>dashed</text>
+                                               </when>
+                                               <otherwise>
+                                                       <text>solid</text>
+                                               </otherwise>
+                                       </choose>
+                                       <text>";</text>
 
+                                       <if test="count(ancestor::*) &lt; 
$maxDepth">
+                                               <apply-templates 
select="*[not(self::s:transition)]"/>
+                                       </if>
 
-                       label="<value-of select="@id"/>";
+                                       label="<value-of select="@id"/>";
 
-                       <apply-templates select="*[not(self::s:transition)]"/>
+                                       <variable name="static_reactions" 
select="s:transition[not(@target)]"/>
 
-                       <variable name="static_reactions" 
select="s:transition[not(@target)]"/>
+                                       <if test="$static_reactions">
+                                               <value-of select="@id"/>
+                                               <text>_static_reactions </text>
+                                               <text>[ </text>
+                                               <call-template 
name="htmlTransitionLabel">
+                                                       <with-param 
name="transitions" select="$static_reactions"/>
+                                                       <with-param 
name="heading" select="'Static Reactions'"/>
+                                               </call-template>
+                                               <text> shape=none];</text>
+                                       </if>
 
-                       <if test="$static_reactions">
-                               <value-of select="@id"/>
-                               <text>_static_reactions </text>
-                               <text>[ </text>
-                               <call-template name="htmlTransitionLabel">
-                                       <with-param name="transitions" 
select="$static_reactions"/>
-                                       <with-param name="heading" 
select="'Static Reactions'"/>
-                               </call-template>
-                               <text> shape=none];</text>
-                       </if>
-               }
+                               }
+                       </when>
+                       <otherwise>
+                               <value-of select="@id"/> 
+                               <text>[shape=box, style="rounded"</text>
+                                       <if test="../@initial = @id">
+                                               <text>,color="green"</text>
+                                       </if>
+                               <text>];</text>
+                       </otherwise>
+               </choose>
        </template>
 
        <template match="s:state[not(.//s:state)]">


Reply via email to