comparison gnv-artifacts/contrib/visualize-transitions.xsl @ 866:ad06ad5f99ea

ISSUE262: Added XSL-Transformation for the Transitionsmodel gnv-artifacts/trunk@1004 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 27 Apr 2010 13:25:22 +0000
parents
children f953c9a559d8
comparison
equal deleted inserted replaced
865:06264920e8d1 866:ad06ad5f99ea
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:xlink="http://www.w3.org/1999/xlink"
5 version="1.0">
6
7 <xsl:output method="text" encoding="UTF-8"/>
8
9 <xsl:param name="base-dir">.</xsl:param>
10
11 <xsl:template match="/">
12 <xsl:text>digraph transition_model {&#xa;</xsl:text>
13 <xsl:apply-templates />
14 <xsl:text>}&#xa;</xsl:text>
15 </xsl:template>
16
17 <xsl:template match="artifact">
18 <xsl:choose>
19 <xsl:when test="@xlink:href != ''">
20 <!-- handle external artifacts -->
21 <xsl:variable name="path">
22 <xsl:call-template name="string-replace-all">
23 <xsl:with-param name="text" select="@xlink:href" />
24 <xsl:with-param name="replace">${artifacts.config.dir}</xsl:with-param>
25 <xsl:with-param name="by" select="$base-dir" />
26 </xsl:call-template>
27 </xsl:variable>
28 <xsl:for-each select="document($path)">
29 <xsl:apply-templates select="/artifact"/>
30 </xsl:for-each>
31 </xsl:when>
32 <xsl:otherwise>
33 <!-- handle internal artifacts -->
34 <xsl:text>subgraph </xsl:text><xsl:value-of select="@name"/>
35 <xsl:text> {&#xa;</xsl:text>
36 <xsl:text> label = "Artefakt: </xsl:text>
37 <xsl:value-of select="@name"/>
38 <xsl:text>";&#xa;</xsl:text>
39 <xsl:apply-templates mode="inside-artifact" select="./states/state"/>
40 <xsl:apply-templates mode="inside-artifact" select="./states/transition"/>
41 <xsl:text>}&#xa;</xsl:text>
42 </xsl:otherwise>
43 </xsl:choose>
44 </xsl:template>
45
46 <xsl:template match="state" mode="inside-artifact">
47 <xsl:text> </xsl:text>
48 <xsl:value-of select="@id"/>
49 <xsl:text disable-output-escaping="yes"
50 > [ shape = "record" label=&lt;&lt;table border="0" cellborder="0" cellpadding="3"&gt;
51 &lt;tr&gt;&lt;td align="center" colspan="2" bgcolor="black"&gt;&lt;font color="white"&gt;</xsl:text>
52 <xsl:value-of select="@id"/>
53 <xsl:text disable-output-escaping="yes"
54 >&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;</xsl:text>
55 <xsl:apply-templates mode="inside-artifact" select="./inputvalues"/>
56 <xsl:text disable-output-escaping="yes"
57 >&lt;/table&gt;&gt;]</xsl:text>
58 <xsl:text>;&#xa;</xsl:text>
59 </xsl:template>
60
61 <xsl:template match="inputvalue" mode="inside-artifact">
62 <xsl:text disable-output-escaping="yes"
63 >&lt;tr&gt;&lt;td align="right"&gt;</xsl:text>
64 <xsl:value-of select="@name"/>
65 <xsl:text disable-output-escaping="yes"
66 >&lt;/td&gt;&lt;td align="left"&gt;</xsl:text>
67 <xsl:value-of select="@type"/>
68 <xsl:text disable-output-escaping="yes"
69 >&lt;/td&gt;&lt;/tr&gt;</xsl:text>
70 </xsl:template>
71
72 <xsl:template match="transition" mode="inside-artifact">
73 <xsl:text> </xsl:text>
74 <xsl:value-of select="from/@state"/>
75 <xsl:text disable-output-escaping="yes"> -&gt; </xsl:text>
76 <xsl:value-of select="to/@state"/>
77 <xsl:apply-templates mode="inside-artifact"/>
78 <xsl:text>;&#xa;</xsl:text>
79 </xsl:template>
80
81 <xsl:template match="condition" mode="inside-artifact">
82 <xsl:text> [ label="</xsl:text>
83 <xsl:value-of select="@inputvalue"/>
84 <xsl:text> </xsl:text>
85 <xsl:value-of select="@operator"/>
86 <xsl:text> </xsl:text>
87 <xsl:value-of select="@value"/>
88 <xsl:text>" ]</xsl:text>
89 </xsl:template>
90
91 <xsl:template match="text()" mode="inside-artifact"/>
92 <xsl:template match="text()"/>
93
94 <xsl:template name="string-replace-all">
95 <xsl:param name="text" />
96 <xsl:param name="replace" />
97 <xsl:param name="by" />
98 <xsl:choose>
99 <xsl:when test="contains($text, $replace)">
100 <xsl:value-of select="substring-before($text,$replace)" />
101 <xsl:value-of select="$by" />
102 <xsl:call-template name="string-replace-all">
103 <xsl:with-param name="text"
104 select="substring-after($text,$replace)" />
105 <xsl:with-param name="replace" select="$replace" />
106 <xsl:with-param name="by" select="$by" />
107 </xsl:call-template>
108 </xsl:when>
109 <xsl:otherwise>
110 <xsl:value-of select="$text" />
111 </xsl:otherwise>
112 </xsl:choose>
113 </xsl:template>
114
115 </xsl:stylesheet>
116

http://dive4elements.wald.intevation.org