1 <?xml version="1.0" ?> 2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" 3 xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"> 4 <xsl:output method="xml" indent="yes" 5 doctype-public="-//W3C//DTD SVG 1.0//EN" 6 doctype-system="http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"/> 7 8 <xsl:variable name="text-style">font-size:10px; font-family:sans-serif;</xsl:variable> 9 10 <!-- Used to generate unique gradient fills for colors given by hex value 11 Search for generate-id to find where its used 12 --> 13 <xsl:key name="fills" match="*" use="@fill"/> 14 15 <xsl:template match="@*|node()"> 16 <xsl:copy> 17 <xsl:apply-templates select="@*|node()"/> 18 </xsl:copy> 19 </xsl:template> 20 21 <xsl:template match="svg:svg"> 22 <svg xmlns="http://www.w3.org/2000/svg"> 23 <!-- Order is important here, so the attributes below overrides the 24 originals, which are copied "wholesale" --> 25 <xsl:apply-templates select="@*" /> 26 27 <defs> 28 <linearGradient id="white" x1="0%" y1="0%" x2="0%" y2="0%"> 29 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 30 </linearGradient> 31 32 <linearGradient id="black" x1="0%" y1="0%" x2="0%" y2="0%"> 33 <stop offset="0%" style="stop-color:rgb(0,0,0);stop-opacity:1"/> 34 </linearGradient> 35 36 <linearGradient id="aquamarine" x1="0%" y1="0%" x2="100%" y2="100%"> 37 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 38 <stop offset="100%" style="stop-color:rgb(127,255,212);stop-opacity:1"/> 39 </linearGradient> 40 41 <linearGradient id="azure" x1="0%" y1="0%" x2="100%" y2="100%"> 42 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 43 <stop offset="100%" style="stop-color:rgb(240,255,255);stop-opacity:1"/> 44 </linearGradient> 45 46 <linearGradient id="blue" x1="0%" y1="0%" x2="100%" y2="100%"> 47 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 48 <stop offset="100%" style="stop-color:rgb(0,0,255);stop-opacity:1"/> 49 </linearGradient> 50 51 <linearGradient id="blueviolet" x1="0%" y1="0%" x2="100%" y2="100%"> 52 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 53 <stop offset="100%" style="stop-color:rgb(138,43,226);stop-opacity:1"/> 54 </linearGradient> 55 56 <linearGradient id="brown" x1="0%" y1="0%" x2="100%" y2="100%"> 57 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 58 <stop offset="100%" style="stop-color:rgb(165,42,42);stop-opacity:1"/> 59 </linearGradient> 60 61 <linearGradient id="cadetblue" x1="0%" y1="0%" x2="100%" y2="100%"> 62 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 63 <stop offset="100%" style="stop-color:rgb(95,158,160);stop-opacity:1"/> 64 </linearGradient> 65 66 <linearGradient id="chocolate" x1="0%" y1="0%" x2="100%" y2="100%"> 67 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 68 <stop offset="100%" style="stop-color:rgb(210,105,30);stop-opacity:1"/> 69 </linearGradient> 70 71 <linearGradient id="cornflowerblue" x1="0%" y1="0%" x2="100%" y2="100%"> 72 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 73 <stop offset="100%" style="stop-color:rgb(100,149,237);stop-opacity:1"/> 74 </linearGradient> 75 76 <linearGradient id="crimson" x1="0%" y1="0%" x2="100%" y2="100%"> 77 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 78 <stop offset="100%" style="stop-color:rgb(220,20,60);stop-opacity:1"/> 79 </linearGradient> 80 81 <linearGradient id="cyan" x1="0%" y1="0%" x2="100%" y2="100%"> 82 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 83 <stop offset="100%" style="stop-color:rgb(0,255,255);stop-opacity:1"/> 84 </linearGradient> 85 86 <linearGradient id="darkgreen" x1="0%" y1="0%" x2="100%" y2="100%"> 87 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 88 <stop offset="100%" style="stop-color:rgb(0,100,0);stop-opacity:1"/> 89 </linearGradient> 90 91 <linearGradient id="darkorange" x1="0%" y1="0%" x2="100%" y2="100%"> 92 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 93 <stop offset="100%" style="stop-color:rgb(255,140,0);stop-opacity:1"/> 94 </linearGradient> 95 96 <linearGradient id="gold" x1="0%" y1="0%" x2="100%" y2="100%"> 97 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 98 <stop offset="100%" style="stop-color:rgb(255,215,0);stop-opacity:1"/> 99 </linearGradient> 100 101 <linearGradient id="gray" x1="0%" y1="0%" x2="100%" y2="100%"> 102 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 103 <stop offset="100%" style="stop-color:rgb(192,192,192);stop-opacity:1"/> 104 </linearGradient> 105 106 <linearGradient id="greenyellow" x1="0%" y1="0%" x2="100%" y2="100%"> 107 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 108 <stop offset="100%" style="stop-color:rgb(173,255,47);stop-opacity:1"/> 109 </linearGradient> 110 111 <linearGradient id="green" x1="0%" y1="0%" x2="100%" y2="100%"> 112 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 113 <stop offset="100%" style="stop-color:rgb(0,255,0);stop-opacity:1"/> 114 </linearGradient> 115 116 <linearGradient id="grey" x1="0%" y1="0%" x2="100%" y2="100%"> 117 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 118 <stop offset="100%" style="stop-color:rgb(192,192,192);stop-opacity:1"/> 119 </linearGradient> 120 121 <linearGradient id="hotpink" x1="0%" y1="0%" x2="100%" y2="100%"> 122 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 123 <stop offset="100%" style="stop-color:rgb(255,105,180);stop-opacity:1"/> 124 </linearGradient> 125 126 <linearGradient id="indianred" x1="0%" y1="0%" x2="100%" y2="100%"> 127 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 128 <stop offset="100%" style="stop-color:rgb(205,92,92);stop-opacity:1"/> 129 </linearGradient> 130 131 <linearGradient id="indigo" x1="0%" y1="0%" x2="100%" y2="100%"> 132 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 133 <stop offset="100%" style="stop-color:rgb(75,0,130);stop-opacity:1"/> 134 </linearGradient> 135 136 <linearGradient id="lavender" x1="0%" y1="0%" x2="100%" y2="100%"> 137 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 138 <stop offset="100%" style="stop-color:rgb(230,230,250);stop-opacity:1"/> 139 </linearGradient> 140 141 <linearGradient id="lightblue" x1="0%" y1="0%" x2="100%" y2="100%"> 142 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 143 <stop offset="100%" style="stop-color:rgb(173,216,230);stop-opacity:1"/> 144 </linearGradient> 145 146 <linearGradient id="lightgray" x1="0%" y1="0%" x2="100%" y2="100%"> 147 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 148 <stop offset="100%" style="stop-color:rgb(211,211,211);stop-opacity:1"/> 149 </linearGradient> 150 151 <linearGradient id="lightgrey" x1="0%" y1="0%" x2="100%" y2="100%"> 152 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 153 <stop offset="100%" style="stop-color:rgb(211,211,211);stop-opacity:1"/> 154 </linearGradient> 155 156 <linearGradient id="magenta" x1="0%" y1="0%" x2="100%" y2="100%"> 157 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 158 <stop offset="100%" style="stop-color:rgb(255,0,255);stop-opacity:1"/> 159 </linearGradient> 160 161 <linearGradient id="maroon" x1="0%" y1="0%" x2="100%" y2="100%"> 162 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 163 <stop offset="100%" style="stop-color:rgb(176,48,96);stop-opacity:1"/> 164 </linearGradient> 165 166 <linearGradient id="mediumblue" x1="0%" y1="0%" x2="100%" y2="100%"> 167 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 168 <stop offset="100%" style="stop-color:rgb(0,0,205);stop-opacity:1"/> 169 </linearGradient> 170 171 <linearGradient id="mediumpurple" x1="0%" y1="0%" x2="100%" y2="100%"> 172 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 173 <stop offset="100%" style="stop-color:rgb(147,112,219);stop-opacity:1"/> 174 </linearGradient> 175 176 <linearGradient id="orange" x1="0%" y1="0%" x2="100%" y2="100%"> 177 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 178 <stop offset="100%" style="stop-color:rgb(255,165,0);stop-opacity:1"/> 179 </linearGradient> 180 181 <linearGradient id="pink" x1="0%" y1="0%" x2="100%" y2="100%"> 182 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 183 <stop offset="100%" style="stop-color:rgb(255,192,203);stop-opacity:1"/> 184 </linearGradient> 185 186 <linearGradient id="purple" x1="0%" y1="0%" x2="100%" y2="100%"> 187 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 188 <stop offset="100%" style="stop-color:rgb(160,32,240);stop-opacity:1"/> 189 </linearGradient> 190 191 <linearGradient id="red" x1="0%" y1="0%" x2="100%" y2="100%"> 192 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 193 <stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1"/> 194 </linearGradient> 195 196 <linearGradient id="steelblue" x1="0%" y1="0%" x2="100%" y2="100%"> 197 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 198 <stop offset="100%" style="stop-color:rgb(70,130,180);stop-opacity:1"/> 199 </linearGradient> 200 201 <linearGradient id="violet" x1="0%" y1="0%" x2="100%" y2="100%"> 202 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 203 <stop offset="100%" style="stop-color:rgb(238,130,238);stop-opacity:1"/> 204 </linearGradient> 205 206 <linearGradient id="yellow" x1="0%" y1="0%" x2="100%" y2="100%"> 207 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 208 <stop offset="100%" style="stop-color:rgb(255,255,0);stop-opacity:1"/> 209 </linearGradient> 210 211 <linearGradient id="none" x1="0%" y1="0%" x2="100%" y2="100%"> 212 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 213 <stop offset="100%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 214 </linearGradient> 215 216 <xsl:for-each select="*//*[generate-id() = generate-id(key('fills',@fill)[1])][substring(@fill,1,1)='#']"> 217 <linearGradient x1="0%" y1="0%" x2="100%" y2="100%"> 218 <xsl:attribute name="id">fill-<xsl:value-of select="substring(@fill,2,6)"/></xsl:attribute> 219 <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/> 220 <stop offset="100%"> 221 <xsl:attribute name="style">stop-color:<xsl:value-of select="@fill" />;stop-opacity:1</xsl:attribute> 222 </stop> 223 </linearGradient> 224 </xsl:for-each> 225 226 </defs> 227 228 229 <xsl:apply-templates /> 230 </svg> 231 </xsl:template> 232 233 <!-- Match the top most "g" --> 234 <xsl:template match="/svg:svg/svg:g"> 235 <g> 236 <xsl:apply-templates select="@*"/> 237 <!-- Graphviz uses a polygon as the background. Don't want a gradient there --> 238 <xsl:for-each select="svg:polygon"> 239 <xsl:copy><xsl:apply-templates select="@*" /></xsl:copy> 240 </xsl:for-each> 241 <xsl:apply-templates select="svg:title|svg:g" /> 242 </g> 243 </xsl:template> 244 245 246 <xsl:template match="svg:text"> 247 <text> 248 <xsl:apply-templates select="@*" /> 249 <xsl:if test="not(@font-family) and not(@font-size)"> 250 <xsl:attribute name="style"><xsl:value-of select="$text-style" /></xsl:attribute> 251 </xsl:if> 252 <xsl:apply-templates select="text()"/> 253 </text> 254 </xsl:template> 255 256 257 <xsl:template match="svg:g"> 258 <xsl:copy> 259 <xsl:apply-templates select="@*" /> 260 <xsl:choose> 261 <!-- Handle linked groups. --> 262 <xsl:when test="svg:a"> 263 <xsl:for-each select="svg:a"> 264 <xsl:copy> 265 <xsl:apply-templates select="@*" /> 266 <xsl:call-template name="group"> 267 <xsl:with-param name="class" select="../@class"/> 268 </xsl:call-template> 269 </xsl:copy> 270 </xsl:for-each> 271 <!-- Handle labels. --> 272 <xsl:apply-templates select="svg:text" /> 273 </xsl:when> 274 <!-- Handle bare groups. --> 275 <xsl:otherwise> 276 <xsl:call-template name="group"/> 277 </xsl:otherwise> 278 </xsl:choose> 279 </xsl:copy> 280 </xsl:template> 281 282 283 <xsl:template name="group"> 284 <xsl:param name="class" select="@class"/> 285 286 <xsl:for-each select="svg:polygon|svg:ellipse"> 287 <xsl:call-template name="poly-shadow" /> 288 </xsl:for-each> 289 290 <xsl:choose> 291 <!-- Rewrite node outlines. --> 292 <xsl:when test="$class='node' and svg:path|svg:polyline"> 293 <xsl:call-template name="node-outline"> 294 <xsl:with-param name="current" select="*[1]"/> 295 <xsl:with-param name="style">shadow</xsl:with-param> 296 </xsl:call-template> 297 </xsl:when> 298 <xsl:otherwise> 299 <xsl:for-each select="svg:path"> 300 <xsl:call-template name="path-shadow-edge" /> 301 </xsl:for-each> 302 </xsl:otherwise> 303 </xsl:choose> 304 305 <xsl:for-each select="svg:polygon|svg:ellipse"> 306 <xsl:sort select="@ry" order="descending" /> 307 <xsl:call-template name="poly-main" /> 308 </xsl:for-each> 309 310 <xsl:choose> 311 <!-- Rewrite node outlines. --> 312 <xsl:when test="$class='node' and svg:path|svg:polyline"> 313 <xsl:call-template name="node-outline"> 314 <xsl:with-param name="current" select="*[1]"/> 315 </xsl:call-template> 316 </xsl:when> 317 <xsl:otherwise> 318 <xsl:for-each select="svg:path"> 319 <path><xsl:apply-templates select="@*" /></path> 320 </xsl:for-each> 321 </xsl:otherwise> 322 </xsl:choose> 323 324 <!-- Handle labels. --> 325 <xsl:apply-templates select="svg:text" /> 326 </xsl:template> 327 328 <xsl:template name="node-outline"> 329 <xsl:param name="path-so-far"/> 330 <xsl:param name="current"/> 331 <xsl:param name="style"/> 332 333 <xsl:choose> 334 <!-- Visit each child element, collecting the path details. --> 335 <xsl:when test="$current"> 336 <xsl:choose> 337 <xsl:when test="local-name($current) = 'path'"> 338 <xsl:call-template name="filter-path"> 339 <xsl:with-param name="path-so-far" select="$path-so-far"/> 340 <xsl:with-param name="point" select="substring-before($current/@d, 'C')"/> 341 <xsl:with-param name="points" select="concat('C', substring-after($current/@d, 'C'))"/> 342 <xsl:with-param name="current" select="$current"/> 343 <xsl:with-param name="style" select="$style"/> 344 </xsl:call-template> 345 </xsl:when> 346 <xsl:when test="local-name($current) = 'polyline'"> 347 <xsl:call-template name="polyline-to-path"> 348 <xsl:with-param name="path-so-far" select="$path-so-far"/> 349 <xsl:with-param name="point" select="concat('M', substring-before($current/@points, ' '))"/> 350 <xsl:with-param name="points" select="substring-after($current/@points, ' ')"/> 351 <xsl:with-param name="current" select="$current"/> 352 <xsl:with-param name="style" select="$style"/> 353 </xsl:call-template> 354 </xsl:when> 355 <xsl:otherwise> 356 <xsl:call-template name="node-outline"> 357 <xsl:with-param name="path-so-far" select="$path-so-far"/> 358 <xsl:with-param name="current" select="$current/following-sibling::*[1]"/> 359 <xsl:with-param name="style" select="$style"/> 360 </xsl:call-template> 361 </xsl:otherwise> 362 </xsl:choose> 363 </xsl:when> 364 <!-- With no more elements to visit, generate the path. --> 365 <xsl:otherwise> 366 <xsl:choose> 367 <xsl:when test="$style = 'shadow'"> 368 <path style="fill: black; stroke: none; fill-opacity:0.15" transform="translate(3,3)" 369 d="{$path-so-far}"/> 370 </xsl:when> 371 <xsl:otherwise> 372 <!-- Provide the path attributes using dynamic colour discoveries. --> 373 <xsl:element name="path"> 374 <xsl:attribute name="d"><xsl:value-of select="$path-so-far"/></xsl:attribute> 375 <xsl:call-template name="make-style-attribute"> 376 <xsl:with-param name="fill" 377 select="normalize-space(substring-after(substring-before(ancestor::*[svg:polygon]/svg:polygon[1]/@style,';'),'fill:'))"/> 378 <xsl:with-param name="fill-explicit" 379 select="@fill"/> 380 <xsl:with-param name="stroke" 381 select="normalize-space(substring-after(substring-before(ancestor::*[svg:polygon]/svg:polygon[1]/@style,';'),'stroke:'))"/> 382 <xsl:with-param name="stroke-explicit">black</xsl:with-param> 383 <xsl:with-param name="none-is-transparent" select="true()"/> 384 </xsl:call-template> 385 </xsl:element> 386 </xsl:otherwise> 387 </xsl:choose> 388 </xsl:otherwise> 389 </xsl:choose> 390 </xsl:template> 391 392 <xsl:template name="filter-path"> 393 <xsl:param name="path-so-far"/> 394 <xsl:param name="point"/> 395 <xsl:param name="points"/> 396 <xsl:param name="current"/> 397 <xsl:param name="style"/> 398 399 <xsl:variable name="next" select="substring-before($points, ' ')"/> 400 <xsl:variable name="remaining" select="substring-after($points, ' ')"/> 401 402 <xsl:choose> 403 <!-- With path points remaining, include the current point if appropriate 404 and visit those remaining. --> 405 <xsl:when test="$remaining"> 406 <xsl:call-template name="filter-path"> 407 <xsl:with-param name="path-so-far" select="concat($path-so-far, ' ', $point)"/> 408 <xsl:with-param name="point" select="$next"/> 409 <xsl:with-param name="points" select="$remaining"/> 410 <xsl:with-param name="current" select="$current"/> 411 <xsl:with-param name="style" select="$style"/> 412 </xsl:call-template> 413 </xsl:when> 414 <!-- With up to one remaining after this point, include the current point, 415 if appropriate, and the one remaining. --> 416 <xsl:otherwise> 417 <xsl:call-template name="node-outline"> 418 <xsl:with-param name="path-so-far" select="concat($path-so-far, ' ', $point, ' ', $points)"/> 419 <xsl:with-param name="current" select="$current/following-sibling::*[1]"/> 420 <xsl:with-param name="style" select="$style"/> 421 <xsl:with-param name="last" select="$current"/> 422 </xsl:call-template> 423 </xsl:otherwise> 424 </xsl:choose> 425 </xsl:template> 426 427 <xsl:template name="polyline-to-path"> 428 <xsl:param name="path-so-far"/> 429 <xsl:param name="point"/> 430 <xsl:param name="points"/> 431 <xsl:param name="current"/> 432 <xsl:param name="style"/> 433 434 <xsl:variable name="next" select="substring-before($points, ' ')"/> 435 <xsl:variable name="remaining" select="substring-after($points, ' ')"/> 436 437 <xsl:choose> 438 <!-- With path points remaining, include the current point if appropriate 439 and visit those remaining. --> 440 <xsl:when test="$remaining"> 441 <xsl:call-template name="polyline-to-path"> 442 <xsl:with-param name="path-so-far" select="concat($path-so-far, ' ', $point)"/> 443 <xsl:with-param name="point" select="concat('L', $next)"/> 444 <xsl:with-param name="points" select="$remaining"/> 445 <xsl:with-param name="current" select="$current"/> 446 <xsl:with-param name="style" select="$style"/> 447 </xsl:call-template> 448 </xsl:when> 449 <!-- With up to one remaining after this point, include the current point, 450 if appropriate, and the one remaining. --> 451 <xsl:otherwise> 452 <xsl:call-template name="node-outline"> 453 <xsl:with-param name="path-so-far" select="concat($path-so-far, ' ', $point, ' L', $points)"/> 454 <xsl:with-param name="current" select="$current/following-sibling::*[1]"/> 455 <xsl:with-param name="style" select="$style"/> 456 <xsl:with-param name="last" select="$current"/> 457 </xsl:call-template> 458 </xsl:otherwise> 459 </xsl:choose> 460 </xsl:template> 461 462 <xsl:template name="poly-shadow"> 463 <xsl:element name="{name()}"> 464 <xsl:apply-templates select="@*"/> 465 <xsl:attribute name="style">fill: black; stroke: none; fill-opacity:0.3</xsl:attribute> 466 <xsl:attribute name="transform">translate(3,3)</xsl:attribute> 467 </xsl:element> 468 </xsl:template> 469 470 <xsl:template name="path-shadow-edge"> 471 <xsl:element name="{name()}"> 472 <xsl:apply-templates select="@*"/> 473 <xsl:attribute name="style">fill: none; stroke: black; stroke-opacity:0.3</xsl:attribute> 474 <xsl:attribute name="transform">translate(3,3)</xsl:attribute> 475 </xsl:element> 476 </xsl:template> 477 478 <xsl:template name="poly-main"> 479 <xsl:element name="{name()}"> 480 <xsl:apply-templates select="@*" /> 481 <xsl:call-template name="make-style-attribute"> 482 <xsl:with-param name="fill" 483 select="normalize-space(substring-after(substring-before(@style,';'),'fill:'))"/> 484 <xsl:with-param name="fill-explicit" 485 select="@fill"/> 486 <xsl:with-param name="stroke" 487 select="normalize-space(substring-after(substring-after(@style,';'),'stroke:'))"/> 488 <xsl:with-param name="stroke-explicit" 489 select="@stroke"/> 490 </xsl:call-template> 491 </xsl:element> 492 </xsl:template> 493 494 <xsl:template name="path-main"> 495 <path> 496 <xsl:apply-templates select="@*" /> 497 <!-- 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 --> 498 <xsl:call-template name="make-style-attribute"> 499 <xsl:with-param name="fill" 500 select="normalize-space(substring-after(substring-before(ancestor::*[svg:polygon]/svg:polygon[1]/@style,';'),'fill:'))"/> 501 <xsl:with-param name="fill-explicit" 502 select="ancestor::*[svg:polygon]/svg:polygon[1]/@fill"/> 503 <xsl:with-param name="stroke" 504 select="normalize-space(substring-after(substring-before(ancestor::*[svg:polygon]/svg:polygon[1]/@style,';'),'stroke:'))"/> 505 <xsl:with-param name="stroke-explicit">black</xsl:with-param> 506 </xsl:call-template> 507 </path> 508 </xsl:template> 509 510 <xsl:template name="make-style-attribute"> 511 <xsl:param name="fill"/> 512 <xsl:param name="fill-explicit"/> 513 <xsl:param name="stroke"/> 514 <xsl:param name="stroke-explicit"/> 515 <xsl:param name="none-is-transparent" select="false()"/> 516 517 <xsl:attribute name="style"> 518 <xsl:choose> 519 <xsl:when test="$fill and (not($none-is-transparent) or $fill != 'none')"> 520 <xsl:call-template name="make-style-fill"> 521 <xsl:with-param name="fill" select="$fill"/> 522 </xsl:call-template> 523 </xsl:when> 524 <xsl:when test="$fill-explicit and (not($none-is-transparent) or $fill-explicit != 'none')"> 525 <xsl:choose> 526 <xsl:when test="starts-with($fill-explicit, '#')"> 527 <xsl:call-template name="make-style-fill"> 528 <xsl:with-param name="fill" select="$fill-explicit"/> 529 </xsl:call-template> 530 </xsl:when> 531 <xsl:otherwise>fill: url(#<xsl:value-of select="$fill-explicit"/>);</xsl:otherwise> 532 </xsl:choose> 533 </xsl:when> 534 <xsl:otherwise>fill: none;</xsl:otherwise> 535 </xsl:choose> 536 <xsl:choose> 537 <xsl:when test="$stroke">stroke: <xsl:value-of select="$stroke"/>;</xsl:when> 538 <xsl:when test="$stroke-explicit">stroke: <xsl:value-of select="$stroke-explicit"/>;</xsl:when> 539 <xsl:otherwise>stroke: black;</xsl:otherwise> 540 </xsl:choose> 541 </xsl:attribute> 542 </xsl:template> 543 544 <xsl:template name="make-style-fill"> 545 <xsl:param name="fill"/> 546 <xsl:choose> 547 <xsl:when test="substring($fill,1,1) = '#'">fill: url(#fill-<xsl:value-of select="substring($fill,2,6)"/>);</xsl:when> 548 <xsl:otherwise>fill: url(#<xsl:value-of select="$fill"/>);</xsl:otherwise> 549 </xsl:choose> 550 </xsl:template> 551 552 </xsl:stylesheet>