File: nothugly.xsl

package info (click to toggle)
ruby-graphviz 1.0.8-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,124 kB
  • ctags: 695
  • sloc: ruby: 7,656; xml: 26; makefile: 17
file content (321 lines) | stat: -rw-r--r-- 13,736 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" 
    xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg">
<xsl:output method="xml" indent="yes"
    doctype-public="-//W3C//DTD SVG 1.0//EN"
    doctype-system="http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"/>

<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy> 
</xsl:template>

<xsl:template match="svg:svg">
  <svg xmlns="http://www.w3.org/2000/svg">
    <!-- Order is important here, so the attributes below overrides the 
         originals, which are copied "wholesale" -->
    <xsl:apply-templates select="@*" />
 
    <defs>
      <linearGradient id="white" x1="0%" y1="0%" x2="0%" y2="0%">
         <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="aquamarine" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(127,255,212);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="azure" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(240,255,255);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="blue" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(0,0,255);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="blueviolet" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(138,43,226);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="brown" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(165,42,42);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="cadetblue" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(95,158,160);stop-opacity:1"/>
      </linearGradient>
      
      <linearGradient id="chocolate" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(210,105,30);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="cornflowerblue" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(100,149,237);stop-opacity:1"/>
      </linearGradient>
      
      <linearGradient id="crimson" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(220,20,60);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="cyan" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(0,255,255);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="darkgreen" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(0,100,0);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="darkorange" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(255,140,0);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="gold" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(255,215,0);stop-opacity:1"/>
      </linearGradient>
      
      <linearGradient id="gray" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(192,192,192);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="greenyellow" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(173,255,47);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="green" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(0,255,0);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="grey" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(192,192,192);stop-opacity:1"/>
      </linearGradient>
      
      <linearGradient id="hotpink" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(255,105,180);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="indianred" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(205,92,92);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="indigo" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(75,0,130);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="lavender" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(230,230,250);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="lightblue" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(173,216,230);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="lightgray" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(211,211,211);stop-opacity:1"/>
      </linearGradient>
      
      <linearGradient id="lightgrey" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(211,211,211);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="magenta" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(255,0,255);stop-opacity:1"/>
      </linearGradient>
      
      <linearGradient id="maroon" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(176,48,96);stop-opacity:1"/>
      </linearGradient>
      
      <linearGradient id="mediumblue" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(0,0,205);stop-opacity:1"/>
      </linearGradient>
      
      <linearGradient id="mediumpurple" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(147,112,219);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="orange" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(255,165,0);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="pink" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(255,192,203);stop-opacity:1"/>
      </linearGradient>
      
      <linearGradient id="purple" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(160,32,240);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="red" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1"/>
      </linearGradient>
      
      <linearGradient id="steelblue" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(70,130,180);stop-opacity:1"/>
      </linearGradient>
      
      <linearGradient id="violet" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(238,130,238);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="yellow" x1="0%" y1="0%" x2="100%" y2="100%">
	<stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
	<stop offset="100%" style="stop-color:rgb(255,255,0);stop-opacity:1"/>
      </linearGradient>

      <linearGradient id="none" x1="0%" y1="0%" x2="100%" y2="100%">
         <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
         <stop offset="100%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
      </linearGradient>
    </defs>

    <xsl:apply-templates />
  </svg>
</xsl:template>

<!-- Match the top most "g" -->
<xsl:template match="/svg:svg/svg:g"> 
  <g>
    <xsl:apply-templates select="@*"/>
    <!-- Graphviz uses a polygon as the background. Don't want a gradient there -->
    <xsl:for-each select="svg:polygon">
      <xsl:copy><xsl:apply-templates select="@*" /></xsl:copy>
    </xsl:for-each>
    <xsl:apply-templates select="svg:title|svg:g" />
  </g>
</xsl:template> 
 

<xsl:template match="svg:text">
  <text>
    <xsl:apply-templates select="@*" />
    <xsl:attribute name="style">font-size:10px; font-family:Verdana</xsl:attribute> 
    <xsl:apply-templates select="text()"/>
  </text>
</xsl:template> 


<xsl:template match="svg:g">
  <xsl:copy>
    <xsl:apply-templates select="@*" />

    <xsl:for-each select="svg:polygon|svg:ellipse">
      <xsl:call-template name="poly-shadow" />
    </xsl:for-each>

    <xsl:choose>
      <xsl:when test="@class='node'">
	<xsl:for-each select="svg:path">
	  <xsl:call-template name="path-shadow" />
	</xsl:for-each>
      </xsl:when>
      <xsl:otherwise>
	<xsl:for-each select="svg:path">
	  <xsl:call-template name="path-shadow-edge" />
	</xsl:for-each>
      </xsl:otherwise>
    </xsl:choose>
  
    <xsl:for-each select="svg:polygon|svg:ellipse|svg:polyline">
      <xsl:sort select="@ry" order="descending" />
      <xsl:call-template name="poly-main" />
    </xsl:for-each>

    <xsl:choose>
      <xsl:when test="@class='node'">
	<xsl:for-each select="svg:path">
	  <xsl:call-template name="path-main" />
	</xsl:for-each>
      </xsl:when>
      <xsl:otherwise>
	<xsl:for-each select="svg:path">
        <path><xsl:apply-templates select="@*" /></path>
	</xsl:for-each>
      </xsl:otherwise>
    </xsl:choose>

    <xsl:apply-templates select="svg:text" />
  </xsl:copy>
</xsl:template>

<xsl:template name="poly-shadow">
        <xsl:element name="{name()}">
          <xsl:apply-templates select="@*"/>
          <xsl:attribute name="style">fill: black; stroke: none; fill-opacity:0.3</xsl:attribute> 
          <xsl:attribute name="transform">translate(3,3)</xsl:attribute>
        </xsl:element>
</xsl:template>

<xsl:template name="path-shadow">
        <xsl:element name="{name()}">
          <xsl:apply-templates select="@*"/>
	  <!-- For some reason this comes out twice, so the opacity is set to 0.15 instead of 0.3 -->
          <xsl:attribute name="style">fill: black; stroke: none; fill-opacity:0.15</xsl:attribute> 
          <xsl:attribute name="transform">translate(3,3)</xsl:attribute>
        </xsl:element>
</xsl:template>

<xsl:template name="path-shadow-edge">
        <xsl:element name="{name()}">
          <xsl:apply-templates select="@*"/>
          <xsl:attribute name="style">fill: none; stroke: black; stroke-opacity:0.3</xsl:attribute> 
          <xsl:attribute name="transform">translate(3,3)</xsl:attribute>
        </xsl:element>
</xsl:template>

<xsl:template name="poly-main">
  <xsl:element name="{name()}">
    <xsl:apply-templates select="@*" />
    <xsl:choose>
      <xsl:when test="@fill != ''">
<xsl:attribute name="style">fill:url(#<xsl:value-of select="@fill"/>);stroke:black;</xsl:attribute></xsl:when>
      <xsl:otherwise><xsl:attribute name="style">fill:url(#<xsl:value-of select="normalize-space(substring-after(substring-before(@style,';'),'fill:'))"/>);stroke:<xsl:value-of select="normalize-space(substring-after(substring-after(@style,';'),'stroke:'))"/>;</xsl:attribute></xsl:otherwise>
    </xsl:choose>
  </xsl:element>
</xsl:template>

<xsl:template name="path-main">
        <path>
          <xsl:apply-templates select="@*" />
	  <!-- This is somewhat broken - the gradient is set based on the position/size of the element it is used with; as a result it doesn't line up properly with the main polygon -->
	  <xsl:attribute name="style">fill:url(#<xsl:value-of select="normalize-space(substring-after(substring-before(../svg:polygon/@style,';'),'fill:'))"/>);stroke:black;</xsl:attribute>
        </path>
</xsl:template>

</xsl:stylesheet>