comparison flys-artifacts/contrib/visualize-transitions.xsl @ 462:ebf049a1eb53

merged flys-artifacts/2.3.1
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:11 +0200
parents 88614ddfc1e3
children a079f4e26001
comparison
equal deleted inserted replaced
441:c4c8137e8f0e 462:ebf049a1eb53
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="@inputvalue"/>
96 <xsl:text> </xsl:text>
97 <xsl:value-of select="@operator"/>
98 <xsl:text> </xsl:text>
99 <xsl:value-of select="@value"/>
100 <xsl:text>" ]</xsl:text>
101 </xsl:template>
102
103 <xsl:template match="text()" mode="inside-artifact"/>
104 <xsl:template match="text()"/>
105
106 <xsl:template name="string-replace-all">
107 <xsl:param name="text" />
108 <xsl:param name="replace" />
109 <xsl:param name="by" />
110 <xsl:choose>
111 <xsl:when test="contains($text, $replace)">
112 <xsl:value-of select="substring-before($text,$replace)" />
113 <xsl:value-of select="$by" />
114 <xsl:call-template name="string-replace-all">
115 <xsl:with-param name="text"
116 select="substring-after($text,$replace)" />
117 <xsl:with-param name="replace" select="$replace" />
118 <xsl:with-param name="by" select="$by" />
119 </xsl:call-template>
120 </xsl:when>
121 <xsl:otherwise>
122 <xsl:value-of select="$text" />
123 </xsl:otherwise>
124 </xsl:choose>
125 </xsl:template>
126
127 </xsl:stylesheet>
128

http://dive4elements.wald.intevation.org