Author: jbeard
Date: Thu Mar 17 16:18:30 2011
New Revision: 1082561
URL: http://svn.apache.org/viewvc?rev=1082561&view=rev
Log:
Started work on scxml-to-dot.xsl, which take scxml documents and converts them
to dot files for the purposes of generating graphical representations.
Added:
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/util/scxml-to-dot.xsl
(with props)
Added: 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=1082561&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/util/scxml-to-dot.xsl
(added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/util/scxml-to-dot.xsl Thu
Mar 17 16:18:30 2011
@@ -0,0 +1,115 @@
+<?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.
+-->
+<!--
+This stylesheet takes as input an scxml document, and produces as output
+a document in the graphviz dot syntax.
+-->
+<stylesheet
+ xmlns="http://www.w3.org/1999/XSL/Transform"
+ xmlns:c="http://commons.apache.org/scxml-js"
+ xmlns:exsl="http://exslt.org/common"
+ xmlns:s="http://www.w3.org/2005/07/scxml"
+ version="1.0">
+ <output method="text"/>
+
+ <template match="/">
+ digraph G {
+ <apply-templates select="*[not(self::s:transition)]"/>
+
+ <apply-templates select="//s:transition"/>
+ }
+ </template>
+
+ <template match="s:scxml | s:state[.//s:state] | s:parallel">
+ subgraph cluster_<value-of select="@id"/> {
+ color="blue";
+ label="<value-of select="@id"/>";
+
+ <apply-templates select="*[not(self::s:transition)]"/>
+ }
+ </template>
+
+ <template match="s:state[not(.//s:state)]">
+ <value-of select="@id"/>;
+ </template>
+
+ <template match="s:transition">
+ <variable name="sourceId" select="../@id"/>
+ <variable name="sourceState" select="//*[@id=$sourceId]"/>
+ <variable name="sourceStatesBasicSubstates"
select="$sourceState//s:state[not(.//s:state)]"/>
+
+ <variable name="sourceBasicStateId">
+ <choose>
+ <when test="$sourceStatesBasicSubstates">
+ <!-- source is a composite state -->
+ <value-of
select="$sourceStatesBasicSubstates[1]/@id"/>
+ </when>
+ <otherwise>
+ <!-- use the first basic substate as
the target -->
+ <value-of select="$sourceId"/>
+ </otherwise>
+ </choose>
+ </variable>
+
+
+ <variable name="targetId">
+ <choose>
+ <when test="@target">
+ <value-of select="@target"/>
+ </when>
+ <otherwise>
+ <value-of select="$sourceId"/>
+ </otherwise>
+ </choose>
+ </variable>
+
+ <variable name="targetState" select="//*[@id=$targetId]"/>
+ <variable name="targetStatesBasicSubstates"
select="$targetState//s:state[not(.//s:state)]"/>
+
+ <variable name="targetBasicStateId">
+ <choose>
+ <when test="$targetStatesBasicSubstates">
+ <!-- target is a composite state -->
+
+ <!-- use the first basic substate as
the target -->
+ <value-of
select="$targetStatesBasicSubstates[1]/@id"/>
+ </when>
+ <otherwise>
+ <!-- target is a basic state -->
+ <value-of select="$targetId"/>
+ </otherwise>
+ </choose>
+ </variable>
+
+ <value-of select="$sourceBasicStateId"/> -> <value-of
select="$targetBasicStateId"/>
+ [
+ <if test="$sourceStatesBasicSubstates">
+ ltail=cluster_<value-of select="$sourceId"/>,
+ </if>
+ <if test="$targetStatesBasicSubstates">
+ lhead=cluster_<value-of select="$targetId"/>,
+ </if>
+ <if test="@event | s:script | @cond">
+ label="<value-of select="@event"/>[<if
test="@cond"><value-of select="@cond"/></if>]"
+ </if>
+ ];
+ </template>
+
+ <template match="s:script"/>
+
+</stylesheet>
Propchange:
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/util/scxml-to-dot.xsl
------------------------------------------------------------------------------
svn:eol-style = native