comparison artifacts/contrib/visualize-transitions.xsl @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-artifacts/contrib/visualize-transitions.xsl@a079f4e26001
children
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!--
4 Copyright (c) 2010 by Intevation GmbH
5
6 This program is free software under the LGPL (>=v2.1)
7 Read the file LGPL.txt coming with the software for details
8 or visit http://www.gnu.org/licenses/ if it does not exist.
9
10 Author: Sascha L. Teichmann (sascha.teichmann@intevation.de)
11 -->
12
13 <xsl:stylesheet
14 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
15 xmlns:xlink="http://www.w3.org/1999/xlink"
16 version="1.0">
17
18 <xsl:output method="text" encoding="UTF-8"/>
19
20 <xsl:param name="base-dir">.</xsl:param>
21
22 <xsl:template match="/">
23 <xsl:text>digraph transition_model {&#xa;</xsl:text>
24 <xsl:apply-templates />
25 <xsl:text>}&#xa;</xsl:text>
26 </xsl:template>
27
28 <xsl:template match="artifact">
29 <xsl:choose>
30 <xsl:when test="@xlink:href != ''">
31 <!-- handle external artifacts -->
32 <xsl:variable name="path">
33 <xsl:call-template name="string-replace-all">
34 <xsl:with-param name="text" select="@xlink:href" />
35 <xsl:with-param name="replace">${artifacts.config.dir}</xsl:with-param>
36 <xsl:with-param name="by" select="$base-dir" />
37 </xsl:call-template>
38 </xsl:variable>
39 <xsl:for-each select="document($path)">
40 <xsl:apply-templates select="/artifact"/>
41 </xsl:for-each>
42 </xsl:when>
43 <xsl:otherwise>
44 <!-- handle internal artifacts -->
45 <xsl:text>subgraph </xsl:text><xsl:value-of select="@name"/>
46 <xsl:text> {&#xa;</xsl:text>
47 <xsl:text> label = "Artefakt: </xsl:text>
48 <xsl:value-of select="@name"/>
49 <xsl:text>";&#xa;</xsl:text>
50 <xsl:apply-templates mode="inside-artifact" select="./states/state"/>
51 <xsl:apply-templates mode="inside-artifact" select="./states/transition"/>
52 <xsl:text>}&#xa;</xsl:text>
53 </xsl:otherwise>
54 </xsl:choose>
55 </xsl:template>
56
57 <xsl:template match="state" mode="inside-artifact">
58 <xsl:text> "</xsl:text>
59 <xsl:value-of select="@id"/>
60 <xsl:text disable-output-escaping="yes"
61 >" [ shape = "record" label=&lt;&lt;table border="0" cellborder="0" cellpadding="3"&gt;
62 &lt;tr&gt;&lt;td align="center" colspan="2" bgcolor="black"&gt;&lt;font color="white"&gt;</xsl:text>
63 <xsl:value-of select="@id"/>
64 <xsl:text disable-output-escaping="yes"
65 >&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;</xsl:text>
66 <xsl:apply-templates mode="inside-artifact" />
67 <xsl:text disable-output-escaping="yes"
68 >&lt;/table&gt;&gt;]</xsl:text>
69 <xsl:text>;&#xa;</xsl:text>
70 </xsl:template>
71
72 <xsl:template match="data" mode="inside-artifact">
73 <xsl:text disable-output-escaping="yes"
74 >&lt;tr&gt;&lt;td align="right"&gt;</xsl:text>
75 <xsl:value-of select="@name"/>
76 <xsl:text disable-output-escaping="yes"
77 >&lt;/td&gt;&lt;td align="left"&gt;</xsl:text>
78 <xsl:value-of select="@type"/>
79 <xsl:text disable-output-escaping="yes"
80 >&lt;/td&gt;&lt;/tr&gt;</xsl:text>
81 </xsl:template>
82
83 <xsl:template match="transition" mode="inside-artifact">
84 <xsl:text> "</xsl:text>
85 <xsl:value-of select="from/@state"/>
86 <xsl:text disable-output-escaping="yes">" -&gt; "</xsl:text>
87 <xsl:value-of select="to/@state"/>
88 <xsl:text>"</xsl:text>
89 <xsl:apply-templates mode="inside-artifact"/>
90 <xsl:text>;&#xa;</xsl:text>
91 </xsl:template>
92
93 <xsl:template match="condition" mode="inside-artifact">
94 <xsl:text> [ label="</xsl:text>
95 <xsl:value-of select="@data"/>
96 <xsl:text> </xsl:text>
97 <xsl:call-template name="readable-operator">
98 <xsl:with-param name="operator" select="@operator"/>
99 </xsl:call-template>
100 <xsl:text> </xsl:text>
101 <xsl:value-of select="@value"/>
102 <xsl:text>" ]</xsl:text>
103 </xsl:template>
104
105 <xsl:template match="text()" mode="inside-artifact"/>
106 <xsl:template match="text()"/>
107
108 <xsl:template name="readable-operator">
109 <xsl:param name="operator" />
110 <xsl:choose>
111 <xsl:when test='$operator = "equal"'>=</xsl:when>
112 <xsl:when test='$operator = "notequal"'>!=</xsl:when>
113 <xsl:otherwise><xsl:value-of select="$operator"/></xsl:otherwise>
114 </xsl:choose>
115 </xsl:template>
116
117 <xsl:template name="string-replace-all">
118 <xsl:param name="text" />
119 <xsl:param name="replace" />
120 <xsl:param name="by" />
121 <xsl:choose>
122 <xsl:when test="contains($text, $replace)">
123 <xsl:value-of select="substring-before($text,$replace)" />
124 <xsl:value-of select="$by" />
125 <xsl:call-template name="string-replace-all">
126 <xsl:with-param name="text"
127 select="substring-after($text,$replace)" />
128 <xsl:with-param name="replace" select="$replace" />
129 <xsl:with-param name="by" select="$by" />
130 </xsl:call-template>
131 </xsl:when>
132 <xsl:otherwise>
133 <xsl:value-of select="$text" />
134 </xsl:otherwise>
135 </xsl:choose>
136 </xsl:template>
137
138 </xsl:stylesheet>
139

http://dive4elements.wald.intevation.org