Mercurial > dive4elements > river
comparison flys-artifacts/contrib/visualize-transitions.xsl @ 351:2d268f9894bb
Added XSL transformation do create Graphviz digraph out of conf.xml
flys-artifacts/trunk@1755 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 28 Apr 2011 09:09:44 +0000 |
parents | |
children | 88614ddfc1e3 |
comparison
equal
deleted
inserted
replaced
350:2465dc296395 | 351:2d268f9894bb |
---|---|
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 {
</xsl:text> | |
24 <xsl:apply-templates /> | |
25 <xsl:text>}
</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> {
</xsl:text> | |
47 <xsl:text> label = "Artefakt: </xsl:text> | |
48 <xsl:value-of select="@name"/> | |
49 <xsl:text>";
</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>}
</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=<<table border="0" cellborder="0" cellpadding="3"> | |
62 <tr><td align="center" colspan="2" bgcolor="black"><font color="white"></xsl:text> | |
63 <xsl:value-of select="@id"/> | |
64 <xsl:text disable-output-escaping="yes" | |
65 ></font></td></tr></xsl:text> | |
66 <xsl:apply-templates mode="inside-artifact" /> | |
67 <xsl:text disable-output-escaping="yes" | |
68 ></table>>]</xsl:text> | |
69 <xsl:text>;
</xsl:text> | |
70 </xsl:template> | |
71 | |
72 <xsl:template match="data" mode="inside-artifact"> | |
73 <xsl:text disable-output-escaping="yes" | |
74 ><tr><td align="right"></xsl:text> | |
75 <xsl:value-of select="@name"/> | |
76 <xsl:text disable-output-escaping="yes" | |
77 ></td><td align="left"></xsl:text> | |
78 <xsl:value-of select="@type"/> | |
79 <xsl:text disable-output-escaping="yes" | |
80 ></td></tr></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">" -> "</xsl:text> | |
87 <xsl:value-of select="to/@state"/> | |
88 <xsl:apply-templates mode="inside-artifact"/> | |
89 <xsl:text>";
</xsl:text> | |
90 </xsl:template> | |
91 | |
92 <xsl:template match="condition" mode="inside-artifact"> | |
93 <xsl:text> [ label="</xsl:text> | |
94 <xsl:value-of select="@inputvalue"/> | |
95 <xsl:text> </xsl:text> | |
96 <xsl:value-of select="@operator"/> | |
97 <xsl:text> </xsl:text> | |
98 <xsl:value-of select="@value"/> | |
99 <xsl:text>" ]</xsl:text> | |
100 </xsl:template> | |
101 | |
102 <xsl:template match="text()" mode="inside-artifact"/> | |
103 <xsl:template match="text()"/> | |
104 | |
105 <xsl:template name="string-replace-all"> | |
106 <xsl:param name="text" /> | |
107 <xsl:param name="replace" /> | |
108 <xsl:param name="by" /> | |
109 <xsl:choose> | |
110 <xsl:when test="contains($text, $replace)"> | |
111 <xsl:value-of select="substring-before($text,$replace)" /> | |
112 <xsl:value-of select="$by" /> | |
113 <xsl:call-template name="string-replace-all"> | |
114 <xsl:with-param name="text" | |
115 select="substring-after($text,$replace)" /> | |
116 <xsl:with-param name="replace" select="$replace" /> | |
117 <xsl:with-param name="by" select="$by" /> | |
118 </xsl:call-template> | |
119 </xsl:when> | |
120 <xsl:otherwise> | |
121 <xsl:value-of select="$text" /> | |
122 </xsl:otherwise> | |
123 </xsl:choose> | |
124 </xsl:template> | |
125 | |
126 </xsl:stylesheet> | |
127 |