Author: jbeard
Date: Thu Mar 17 16:20:57 2011
New Revision: 1082573

URL: http://svn.apache.org/viewvc?rev=1082573&view=rev
Log:
Added code to allow rooting at an arbitrary node, as specified by an id.

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=1082573&r1=1082572&r2=1082573&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:57 2011
@@ -32,6 +32,7 @@ a document in the graphviz dot syntax.
        <param name="maxDepth" select="9999"/>
        <param name="printScript" select="false()"/>
        <param name="printCondition" select="false()"/>
+       <param name="startAtNodeWithId"/>
 
        <template name="htmlTransitionLabel">
                <param name="transitions"/>
@@ -92,26 +93,51 @@ a document in the graphviz dot syntax.
 
                        compound=true; 
 
-                       <apply-templates select="*[not(self::s:transition)]"/>
+                       <choose>
+                               <when test="$startAtNodeWithId">
+                                       <apply-templates 
select="$states[@id=$startAtNodeWithId]"/>
+                               </when>
+                               <otherwise>
+                                       <apply-templates 
select="*[not(self::s:transition)]"/>
+                               </otherwise>
+                       </choose>
 
-                       <for-each select="$states">
-                               <variable name="fromState" select="."/>
+                       <choose>
+                               <when test="$startAtNodeWithId">
+                                       <call-template name="genTransitions">
+                                               <with-param name="legalStates" 
select="$states[ancestor-or-self::*/@id=$startAtNodeWithId]"/>
+                                       </call-template>
+                               </when>
+                               <otherwise>
+                                       <call-template name="genTransitions">
+                                               <with-param name="legalStates" 
select="$states"/>
+                                       </call-template>
+                               </otherwise>
+                       </choose>
 
-                               <for-each select="$states">
-                                       <variable name="toState" select="."/>
-                                       
-                                       <variable name="transitions" 
select="$fromState/s:transition[@target=$toState/@id]"/>
+               }
+       </template>
 
-                                       <if test="$transitions">
-                                               <call-template 
name="transition-template">
-                                                       <with-param 
name="transitions" select="$transitions"/>
-                                                       <with-param 
name="sourceState" select="$fromState"/>
-                                                       <with-param 
name="targetState" select="$toState"/>
-                                               </call-template>
-                                       </if>
-                               </for-each>
+       <template name="genTransitions">
+               <param name="legalStates"/>
+               
+               <for-each select="$legalStates">
+                       <variable name="fromState" select="."/>
+
+                       <for-each select="$legalStates">
+                               <variable name="toState" select="."/>
+                               
+                               <variable name="transitions" 
select="$fromState/s:transition[@target=$toState/@id]"/>
+
+                               <if test="$transitions">
+                                       <call-template 
name="transition-template">
+                                               <with-param name="transitions" 
select="$transitions"/>
+                                               <with-param name="sourceState" 
select="$fromState"/>
+                                               <with-param name="targetState" 
select="$toState"/>
+                                       </call-template>
+                               </if>
                        </for-each>
-               }
+               </for-each>
        </template>
 
        <template match="s:scxml | s:state[.//s:state] | s:parallel">


Reply via email to