1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/resources/notugly.xsl Sun Nov 01 23:29:31 2015 +0100
1.3 @@ -0,0 +1,613 @@
1.4 +<?xml version="1.0" ?>
1.5 +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
1.6 + xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg">
1.7 +<xsl:output method="xml" indent="yes"
1.8 + doctype-public="-//W3C//DTD SVG 1.0//EN"
1.9 + doctype-system="http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"/>
1.10 +
1.11 +<xsl:variable name="text-style">font-size:10px; font-family:sans-serif;</xsl:variable>
1.12 +
1.13 +<!-- Used to generate unique gradient fills for colors given by hex value
1.14 + Search for generate-id to find where its used
1.15 +-->
1.16 +<xsl:key name="fills" match="*" use="@fill"/>
1.17 +
1.18 +<xsl:template match="@*|node()">
1.19 + <xsl:copy>
1.20 + <xsl:apply-templates select="@*|node()"/>
1.21 + </xsl:copy>
1.22 +</xsl:template>
1.23 +
1.24 +<xsl:template match="svg:svg">
1.25 + <svg xmlns="http://www.w3.org/2000/svg">
1.26 + <!-- Order is important here, so the attributes below overrides the
1.27 + originals, which are copied "wholesale" -->
1.28 + <xsl:apply-templates select="@*" />
1.29 +
1.30 + <defs>
1.31 + <linearGradient id="white" x1="0%" y1="0%" x2="0%" y2="0%">
1.32 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.33 + </linearGradient>
1.34 +
1.35 + <linearGradient id="black" x1="0%" y1="0%" x2="0%" y2="0%">
1.36 + <stop offset="0%" style="stop-color:rgb(0,0,0);stop-opacity:1"/>
1.37 + </linearGradient>
1.38 +
1.39 + <linearGradient id="aquamarine" x1="0%" y1="0%" x2="100%" y2="100%">
1.40 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.41 + <stop offset="100%" style="stop-color:rgb(127,255,212);stop-opacity:1"/>
1.42 + </linearGradient>
1.43 +
1.44 + <linearGradient id="azure" x1="0%" y1="0%" x2="100%" y2="100%">
1.45 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.46 + <stop offset="100%" style="stop-color:rgb(240,255,255);stop-opacity:1"/>
1.47 + </linearGradient>
1.48 +
1.49 + <linearGradient id="blue" x1="0%" y1="0%" x2="100%" y2="100%">
1.50 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.51 + <stop offset="100%" style="stop-color:rgb(0,0,255);stop-opacity:1"/>
1.52 + </linearGradient>
1.53 +
1.54 + <linearGradient id="blueviolet" x1="0%" y1="0%" x2="100%" y2="100%">
1.55 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.56 + <stop offset="100%" style="stop-color:rgb(138,43,226);stop-opacity:1"/>
1.57 + </linearGradient>
1.58 +
1.59 + <linearGradient id="brown" x1="0%" y1="0%" x2="100%" y2="100%">
1.60 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.61 + <stop offset="100%" style="stop-color:rgb(165,42,42);stop-opacity:1"/>
1.62 + </linearGradient>
1.63 +
1.64 + <linearGradient id="cadetblue" x1="0%" y1="0%" x2="100%" y2="100%">
1.65 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.66 + <stop offset="100%" style="stop-color:rgb(95,158,160);stop-opacity:1"/>
1.67 + </linearGradient>
1.68 +
1.69 + <linearGradient id="chocolate" x1="0%" y1="0%" x2="100%" y2="100%">
1.70 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.71 + <stop offset="100%" style="stop-color:rgb(210,105,30);stop-opacity:1"/>
1.72 + </linearGradient>
1.73 +
1.74 + <linearGradient id="cornflowerblue" x1="0%" y1="0%" x2="100%" y2="100%">
1.75 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.76 + <stop offset="100%" style="stop-color:rgb(100,149,237);stop-opacity:1"/>
1.77 + </linearGradient>
1.78 +
1.79 + <linearGradient id="crimson" x1="0%" y1="0%" x2="100%" y2="100%">
1.80 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.81 + <stop offset="100%" style="stop-color:rgb(220,20,60);stop-opacity:1"/>
1.82 + </linearGradient>
1.83 +
1.84 + <linearGradient id="cyan" x1="0%" y1="0%" x2="100%" y2="100%">
1.85 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.86 + <stop offset="100%" style="stop-color:rgb(0,255,255);stop-opacity:1"/>
1.87 + </linearGradient>
1.88 +
1.89 + <linearGradient id="darkgreen" x1="0%" y1="0%" x2="100%" y2="100%">
1.90 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.91 + <stop offset="100%" style="stop-color:rgb(0,100,0);stop-opacity:1"/>
1.92 + </linearGradient>
1.93 +
1.94 + <linearGradient id="darkorange" x1="0%" y1="0%" x2="100%" y2="100%">
1.95 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.96 + <stop offset="100%" style="stop-color:rgb(255,140,0);stop-opacity:1"/>
1.97 + </linearGradient>
1.98 +
1.99 + <linearGradient id="gold" x1="0%" y1="0%" x2="100%" y2="100%">
1.100 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.101 + <stop offset="100%" style="stop-color:rgb(255,215,0);stop-opacity:1"/>
1.102 + </linearGradient>
1.103 +
1.104 + <linearGradient id="gray" x1="0%" y1="0%" x2="100%" y2="100%">
1.105 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.106 + <stop offset="100%" style="stop-color:rgb(192,192,192);stop-opacity:1"/>
1.107 + </linearGradient>
1.108 +
1.109 + <linearGradient id="greenyellow" x1="0%" y1="0%" x2="100%" y2="100%">
1.110 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.111 + <stop offset="100%" style="stop-color:rgb(173,255,47);stop-opacity:1"/>
1.112 + </linearGradient>
1.113 +
1.114 + <linearGradient id="green" x1="0%" y1="0%" x2="100%" y2="100%">
1.115 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.116 + <stop offset="100%" style="stop-color:rgb(0,255,0);stop-opacity:1"/>
1.117 + </linearGradient>
1.118 +
1.119 + <linearGradient id="grey" x1="0%" y1="0%" x2="100%" y2="100%">
1.120 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.121 + <stop offset="100%" style="stop-color:rgb(192,192,192);stop-opacity:1"/>
1.122 + </linearGradient>
1.123 +
1.124 + <linearGradient id="hotpink" x1="0%" y1="0%" x2="100%" y2="100%">
1.125 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.126 + <stop offset="100%" style="stop-color:rgb(255,105,180);stop-opacity:1"/>
1.127 + </linearGradient>
1.128 +
1.129 + <linearGradient id="indianred" x1="0%" y1="0%" x2="100%" y2="100%">
1.130 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.131 + <stop offset="100%" style="stop-color:rgb(205,92,92);stop-opacity:1"/>
1.132 + </linearGradient>
1.133 +
1.134 + <linearGradient id="indigo" x1="0%" y1="0%" x2="100%" y2="100%">
1.135 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.136 + <stop offset="100%" style="stop-color:rgb(75,0,130);stop-opacity:1"/>
1.137 + </linearGradient>
1.138 +
1.139 + <linearGradient id="lavender" x1="0%" y1="0%" x2="100%" y2="100%">
1.140 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.141 + <stop offset="100%" style="stop-color:rgb(230,230,250);stop-opacity:1"/>
1.142 + </linearGradient>
1.143 +
1.144 + <linearGradient id="lightblue" x1="0%" y1="0%" x2="100%" y2="100%">
1.145 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.146 + <stop offset="100%" style="stop-color:rgb(173,216,230);stop-opacity:1"/>
1.147 + </linearGradient>
1.148 +
1.149 + <linearGradient id="lightgray" x1="0%" y1="0%" x2="100%" y2="100%">
1.150 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.151 + <stop offset="100%" style="stop-color:rgb(211,211,211);stop-opacity:1"/>
1.152 + </linearGradient>
1.153 +
1.154 + <linearGradient id="lightgrey" x1="0%" y1="0%" x2="100%" y2="100%">
1.155 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.156 + <stop offset="100%" style="stop-color:rgb(211,211,211);stop-opacity:1"/>
1.157 + </linearGradient>
1.158 +
1.159 + <linearGradient id="magenta" x1="0%" y1="0%" x2="100%" y2="100%">
1.160 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.161 + <stop offset="100%" style="stop-color:rgb(255,0,255);stop-opacity:1"/>
1.162 + </linearGradient>
1.163 +
1.164 + <linearGradient id="maroon" x1="0%" y1="0%" x2="100%" y2="100%">
1.165 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.166 + <stop offset="100%" style="stop-color:rgb(176,48,96);stop-opacity:1"/>
1.167 + </linearGradient>
1.168 +
1.169 + <linearGradient id="mediumblue" x1="0%" y1="0%" x2="100%" y2="100%">
1.170 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.171 + <stop offset="100%" style="stop-color:rgb(0,0,205);stop-opacity:1"/>
1.172 + </linearGradient>
1.173 +
1.174 + <linearGradient id="mediumpurple" x1="0%" y1="0%" x2="100%" y2="100%">
1.175 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.176 + <stop offset="100%" style="stop-color:rgb(147,112,219);stop-opacity:1"/>
1.177 + </linearGradient>
1.178 +
1.179 + <linearGradient id="orange" x1="0%" y1="0%" x2="100%" y2="100%">
1.180 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.181 + <stop offset="100%" style="stop-color:rgb(255,165,0);stop-opacity:1"/>
1.182 + </linearGradient>
1.183 +
1.184 + <linearGradient id="pink" x1="0%" y1="0%" x2="100%" y2="100%">
1.185 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.186 + <stop offset="100%" style="stop-color:rgb(255,192,203);stop-opacity:1"/>
1.187 + </linearGradient>
1.188 +
1.189 + <linearGradient id="purple" x1="0%" y1="0%" x2="100%" y2="100%">
1.190 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.191 + <stop offset="100%" style="stop-color:rgb(160,32,240);stop-opacity:1"/>
1.192 + </linearGradient>
1.193 +
1.194 + <linearGradient id="red" x1="0%" y1="0%" x2="100%" y2="100%">
1.195 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.196 + <stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1"/>
1.197 + </linearGradient>
1.198 +
1.199 + <linearGradient id="steelblue" x1="0%" y1="0%" x2="100%" y2="100%">
1.200 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.201 + <stop offset="100%" style="stop-color:rgb(70,130,180);stop-opacity:1"/>
1.202 + </linearGradient>
1.203 +
1.204 + <linearGradient id="violet" x1="0%" y1="0%" x2="100%" y2="100%">
1.205 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.206 + <stop offset="100%" style="stop-color:rgb(238,130,238);stop-opacity:1"/>
1.207 + </linearGradient>
1.208 +
1.209 + <linearGradient id="yellow" x1="0%" y1="0%" x2="100%" y2="100%">
1.210 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.211 + <stop offset="100%" style="stop-color:rgb(255,255,0);stop-opacity:1"/>
1.212 + </linearGradient>
1.213 +
1.214 + <linearGradient id="none" x1="0%" y1="0%" x2="100%" y2="100%">
1.215 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.216 + <stop offset="100%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.217 + </linearGradient>
1.218 +
1.219 + <xsl:for-each select="*//*[generate-id() = generate-id(key('fills',@fill)[1])][substring(@fill,1,1)='#']">
1.220 + <linearGradient x1="0%" y1="0%" x2="100%" y2="100%">
1.221 + <xsl:attribute name="id">fill-<xsl:value-of select="substring(@fill,2,6)"/></xsl:attribute>
1.222 + <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"/>
1.223 + <stop offset="100%">
1.224 + <xsl:attribute name="style">stop-color:<xsl:value-of select="@fill" />;stop-opacity:1</xsl:attribute>
1.225 + </stop>
1.226 + </linearGradient>
1.227 + </xsl:for-each>
1.228 +
1.229 + </defs>
1.230 +
1.231 +
1.232 + <xsl:apply-templates />
1.233 + </svg>
1.234 +</xsl:template>
1.235 +
1.236 +<!-- Match the top most "g" -->
1.237 +<xsl:template match="/svg:svg/svg:g">
1.238 + <g>
1.239 + <xsl:apply-templates select="@*"/>
1.240 + <!-- Graphviz uses a polygon as the background. Don't want a gradient there -->
1.241 + <xsl:for-each select="svg:polygon">
1.242 + <xsl:copy><xsl:apply-templates select="@*" /></xsl:copy>
1.243 + </xsl:for-each>
1.244 + <xsl:apply-templates select="svg:title|svg:g" />
1.245 + </g>
1.246 +</xsl:template>
1.247 +
1.248 +
1.249 +<xsl:template match="svg:text">
1.250 + <text>
1.251 + <xsl:apply-templates select="@*" />
1.252 + <xsl:if test="not(@font-family) and not(@font-size)">
1.253 + <xsl:attribute name="style"><xsl:value-of select="$text-style" /></xsl:attribute>
1.254 + </xsl:if>
1.255 + <xsl:apply-templates select="text()"/>
1.256 + </text>
1.257 +</xsl:template>
1.258 +
1.259 +
1.260 +<xsl:template match="svg:g">
1.261 + <xsl:copy>
1.262 + <xsl:apply-templates select="@*" />
1.263 + <xsl:choose>
1.264 + <!-- Handle linked groups. -->
1.265 + <xsl:when test="svg:a">
1.266 + <xsl:for-each select="svg:a">
1.267 + <xsl:copy>
1.268 + <xsl:apply-templates select="@*" />
1.269 + <xsl:call-template name="group">
1.270 + <xsl:with-param name="class" select="../@class"/>
1.271 + </xsl:call-template>
1.272 + </xsl:copy>
1.273 + </xsl:for-each>
1.274 + </xsl:when>
1.275 + <!-- Handle bare groups. -->
1.276 + <xsl:otherwise>
1.277 + <xsl:call-template name="group"/>
1.278 + </xsl:otherwise>
1.279 + </xsl:choose>
1.280 + </xsl:copy>
1.281 +</xsl:template>
1.282 +
1.283 +
1.284 +<xsl:template name="group">
1.285 + <xsl:param name="class" select="@class"/>
1.286 +
1.287 + <xsl:for-each select="svg:polygon|svg:ellipse">
1.288 + <xsl:call-template name="poly-shadow" />
1.289 + </xsl:for-each>
1.290 +
1.291 + <xsl:choose>
1.292 + <!-- Rewrite node outlines. -->
1.293 + <xsl:when test="$class='node' and svg:path|svg:polyline">
1.294 + <xsl:call-template name="node-outline">
1.295 + <xsl:with-param name="current" select="*[1]"/>
1.296 + <xsl:with-param name="style">shadow</xsl:with-param>
1.297 + <xsl:with-param name="first" select="true()"/>
1.298 + </xsl:call-template>
1.299 + </xsl:when>
1.300 + <xsl:otherwise>
1.301 + <xsl:for-each select="svg:path">
1.302 + <xsl:call-template name="path-shadow-edge" />
1.303 + </xsl:for-each>
1.304 + </xsl:otherwise>
1.305 + </xsl:choose>
1.306 +
1.307 + <xsl:for-each select="svg:polygon|svg:ellipse">
1.308 + <xsl:sort select="@ry" order="descending" />
1.309 + <xsl:call-template name="poly-main" />
1.310 + </xsl:for-each>
1.311 +
1.312 + <xsl:choose>
1.313 + <!-- Rewrite node outlines. -->
1.314 + <xsl:when test="$class='node' and svg:path">
1.315 + <xsl:for-each select="svg:path">
1.316 + <xsl:call-template name="node-outline">
1.317 + <xsl:with-param name="current" select="."/>
1.318 + <xsl:with-param name="first" select="true()"/>
1.319 + </xsl:call-template>
1.320 + </xsl:for-each>
1.321 + </xsl:when>
1.322 + <xsl:when test="$class='node' and svg:polyline">
1.323 + <xsl:for-each select="svg:polyline">
1.324 + <xsl:call-template name="node-outline">
1.325 + <xsl:with-param name="current" select="."/>
1.326 + <xsl:with-param name="first" select="true()"/>
1.327 + </xsl:call-template>
1.328 + </xsl:for-each>
1.329 + </xsl:when>
1.330 + <xsl:otherwise>
1.331 + <xsl:for-each select="svg:path">
1.332 + <path><xsl:apply-templates select="@*" /></path>
1.333 + </xsl:for-each>
1.334 + </xsl:otherwise>
1.335 + </xsl:choose>
1.336 +
1.337 + <xsl:apply-templates select="svg:text" />
1.338 +</xsl:template>
1.339 +
1.340 +<xsl:template name="node-outline">
1.341 + <xsl:param name="path-so-far"/>
1.342 + <xsl:param name="current"/>
1.343 + <xsl:param name="style"/>
1.344 + <xsl:param name="first" select="false()"/>
1.345 +
1.346 + <xsl:choose>
1.347 + <!-- Visit each child element, collecting the path details. -->
1.348 + <xsl:when test="$current">
1.349 + <xsl:choose>
1.350 + <xsl:when test="local-name($current) = 'path'">
1.351 + <xsl:call-template name="filter-path">
1.352 + <xsl:with-param name="path-so-far" select="$path-so-far"/>
1.353 + <xsl:with-param name="point" select="substring-before($current/@d, 'C')"/>
1.354 + <xsl:with-param name="points" select="concat('C', substring-after($current/@d, 'C'))"/>
1.355 + <xsl:with-param name="current" select="$current"/>
1.356 + <xsl:with-param name="style" select="$style"/>
1.357 + <xsl:with-param name="include" select="$first"/>
1.358 + </xsl:call-template>
1.359 + </xsl:when>
1.360 + <xsl:when test="local-name($current) = 'polyline'">
1.361 + <xsl:call-template name="polyline-to-path">
1.362 + <xsl:with-param name="path-so-far" select="$path-so-far"/>
1.363 + <xsl:with-param name="point" select="concat('M', substring-before($current/@points, ' '))"/>
1.364 + <xsl:with-param name="points" select="substring-after($current/@points, ' ')"/>
1.365 + <xsl:with-param name="current" select="$current"/>
1.366 + <xsl:with-param name="style" select="$style"/>
1.367 + <xsl:with-param name="include" select="$first"/>
1.368 + </xsl:call-template>
1.369 + </xsl:when>
1.370 + <xsl:otherwise>
1.371 + <xsl:call-template name="node-outline">
1.372 + <xsl:with-param name="path-so-far" select="$path-so-far"/>
1.373 + <xsl:with-param name="current" select="$current/following-sibling::*[1]"/>
1.374 + <xsl:with-param name="style" select="$style"/>
1.375 + <xsl:with-param name="first" select="$first"/>
1.376 + </xsl:call-template>
1.377 + </xsl:otherwise>
1.378 + </xsl:choose>
1.379 + </xsl:when>
1.380 + <!-- With no more elements to visit, generate the path. -->
1.381 + <xsl:otherwise>
1.382 + <xsl:choose>
1.383 + <xsl:when test="$style = 'shadow'">
1.384 + <path style="fill: black; stroke: none; fill-opacity:0.15" transform="translate(3,3)"
1.385 + d="{$path-so-far}"/>
1.386 + </xsl:when>
1.387 + <xsl:otherwise>
1.388 + <!-- Provide the path attributes using dynamic colour discoveries. -->
1.389 + <xsl:element name="path">
1.390 + <xsl:attribute name="d"><xsl:value-of select="$path-so-far"/></xsl:attribute>
1.391 + <xsl:call-template name="make-style-attribute">
1.392 + <xsl:with-param name="fill"
1.393 + select="normalize-space(substring-after(substring-before(ancestor::*[svg:polygon]/svg:polygon[1]/@style,';'),'fill:'))"/>
1.394 + <xsl:with-param name="fill-explicit"
1.395 + select="@fill"/>
1.396 + <xsl:with-param name="stroke"
1.397 + select="normalize-space(substring-after(substring-before(ancestor::*[svg:polygon]/svg:polygon[1]/@style,';'),'stroke:'))"/>
1.398 + <xsl:with-param name="stroke-explicit">black</xsl:with-param>
1.399 + <xsl:with-param name="none-is-transparent" select="true()"/>
1.400 + </xsl:call-template>
1.401 + </xsl:element>
1.402 + </xsl:otherwise>
1.403 + </xsl:choose>
1.404 + </xsl:otherwise>
1.405 + </xsl:choose>
1.406 +</xsl:template>
1.407 +
1.408 +<xsl:template name="filter-path">
1.409 + <xsl:param name="path-so-far"/>
1.410 + <xsl:param name="point"/>
1.411 + <xsl:param name="points"/>
1.412 + <xsl:param name="current"/>
1.413 + <xsl:param name="style"/>
1.414 + <xsl:param name="include" select="true()"/>
1.415 +
1.416 + <xsl:variable name="next" select="substring-before($points, ' ')"/>
1.417 + <xsl:variable name="remaining" select="substring-after($points, ' ')"/>
1.418 +
1.419 + <xsl:choose>
1.420 + <!-- With path points remaining, include the current point if appropriate
1.421 + and visit those remaining. -->
1.422 + <xsl:when test="$remaining">
1.423 + <xsl:choose>
1.424 + <xsl:when test="$include">
1.425 + <xsl:call-template name="filter-path">
1.426 + <xsl:with-param name="path-so-far" select="concat($path-so-far, ' ', $point)"/>
1.427 + <xsl:with-param name="point" select="$next"/>
1.428 + <xsl:with-param name="points" select="$remaining"/>
1.429 + <xsl:with-param name="current" select="$current"/>
1.430 + <xsl:with-param name="style" select="$style"/>
1.431 + </xsl:call-template>
1.432 + </xsl:when>
1.433 + <xsl:otherwise>
1.434 + <xsl:call-template name="filter-path">
1.435 + <xsl:with-param name="path-so-far" select="$path-so-far"/>
1.436 + <xsl:with-param name="point" select="$next"/>
1.437 + <xsl:with-param name="points" select="$remaining"/>
1.438 + <xsl:with-param name="current" select="$current"/>
1.439 + <xsl:with-param name="style" select="$style"/>
1.440 + </xsl:call-template>
1.441 + </xsl:otherwise>
1.442 + </xsl:choose>
1.443 + </xsl:when>
1.444 + <!-- With up to one remaining after this point, include the current point,
1.445 + if appropriate, and the one remaining. -->
1.446 + <xsl:otherwise>
1.447 + <xsl:choose>
1.448 + <xsl:when test="$include">
1.449 + <xsl:call-template name="node-outline">
1.450 + <xsl:with-param name="path-so-far" select="concat($path-so-far, ' ', $point, ' ', $points)"/>
1.451 + <xsl:with-param name="current" select="$current/following-sibling::*[1]"/>
1.452 + <xsl:with-param name="style" select="$style"/>
1.453 + </xsl:call-template>
1.454 + </xsl:when>
1.455 + <xsl:otherwise>
1.456 + <xsl:call-template name="node-outline">
1.457 + <xsl:with-param name="path-so-far" select="concat($path-so-far, ' ', $points)"/>
1.458 + <xsl:with-param name="current" select="$current/following-sibling::*[1]"/>
1.459 + <xsl:with-param name="style" select="$style"/>
1.460 + </xsl:call-template>
1.461 + </xsl:otherwise>
1.462 + </xsl:choose>
1.463 + </xsl:otherwise>
1.464 + </xsl:choose>
1.465 +</xsl:template>
1.466 +
1.467 +<xsl:template name="polyline-to-path">
1.468 + <xsl:param name="path-so-far"/>
1.469 + <xsl:param name="point"/>
1.470 + <xsl:param name="points"/>
1.471 + <xsl:param name="current"/>
1.472 + <xsl:param name="style"/>
1.473 + <xsl:param name="include" select="true()"/>
1.474 +
1.475 + <xsl:variable name="next" select="substring-before($points, ' ')"/>
1.476 + <xsl:variable name="remaining" select="substring-after($points, ' ')"/>
1.477 +
1.478 + <xsl:choose>
1.479 + <!-- With path points remaining, include the current point if appropriate
1.480 + and visit those remaining. -->
1.481 + <xsl:when test="$remaining">
1.482 + <xsl:choose>
1.483 + <xsl:when test="$include">
1.484 + <xsl:call-template name="polyline-to-path">
1.485 + <xsl:with-param name="path-so-far" select="concat($path-so-far, ' ', $point)"/>
1.486 + <xsl:with-param name="point" select="concat('L', $next)"/>
1.487 + <xsl:with-param name="points" select="$remaining"/>
1.488 + <xsl:with-param name="current" select="$current"/>
1.489 + <xsl:with-param name="style" select="$style"/>
1.490 + </xsl:call-template>
1.491 + </xsl:when>
1.492 + <xsl:otherwise>
1.493 + <xsl:call-template name="polyline-to-path">
1.494 + <xsl:with-param name="path-so-far" select="$path-so-far"/>
1.495 + <xsl:with-param name="point" select="concat('L', $next)"/>
1.496 + <xsl:with-param name="points" select="$remaining"/>
1.497 + <xsl:with-param name="current" select="$current"/>
1.498 + <xsl:with-param name="style" select="$style"/>
1.499 + </xsl:call-template>
1.500 + </xsl:otherwise>
1.501 + </xsl:choose>
1.502 + </xsl:when>
1.503 + <!-- With up to one remaining after this point, include the current point,
1.504 + if appropriate, and the one remaining. -->
1.505 + <xsl:otherwise>
1.506 + <xsl:choose>
1.507 + <xsl:when test="$include">
1.508 + <xsl:call-template name="node-outline">
1.509 + <xsl:with-param name="path-so-far" select="concat($path-so-far, ' ', $point, ' L', $points)"/>
1.510 + <xsl:with-param name="current" select="$current/following-sibling::*[2]"/>
1.511 + <xsl:with-param name="style" select="$style"/>
1.512 + </xsl:call-template>
1.513 + </xsl:when>
1.514 + <xsl:otherwise>
1.515 + <xsl:call-template name="node-outline">
1.516 + <xsl:with-param name="path-so-far" select="concat($path-so-far, ' L', $points)"/>
1.517 + <xsl:with-param name="current" select="$current/following-sibling::*[1]"/>
1.518 + <xsl:with-param name="style" select="$style"/>
1.519 + </xsl:call-template>
1.520 + </xsl:otherwise>
1.521 + </xsl:choose>
1.522 + </xsl:otherwise>
1.523 + </xsl:choose>
1.524 +</xsl:template>
1.525 +
1.526 +<xsl:template name="poly-shadow">
1.527 + <xsl:element name="{name()}">
1.528 + <xsl:apply-templates select="@*"/>
1.529 + <xsl:attribute name="style">fill: black; stroke: none; fill-opacity:0.3</xsl:attribute>
1.530 + <xsl:attribute name="transform">translate(3,3)</xsl:attribute>
1.531 + </xsl:element>
1.532 +</xsl:template>
1.533 +
1.534 +<xsl:template name="path-shadow-edge">
1.535 + <xsl:element name="{name()}">
1.536 + <xsl:apply-templates select="@*"/>
1.537 + <xsl:attribute name="style">fill: none; stroke: black; stroke-opacity:0.3</xsl:attribute>
1.538 + <xsl:attribute name="transform">translate(3,3)</xsl:attribute>
1.539 + </xsl:element>
1.540 +</xsl:template>
1.541 +
1.542 +<xsl:template name="poly-main">
1.543 + <xsl:element name="{name()}">
1.544 + <xsl:apply-templates select="@*" />
1.545 + <xsl:call-template name="make-style-attribute">
1.546 + <xsl:with-param name="fill"
1.547 + select="normalize-space(substring-after(substring-before(@style,';'),'fill:'))"/>
1.548 + <xsl:with-param name="fill-explicit"
1.549 + select="@fill"/>
1.550 + <xsl:with-param name="stroke"
1.551 + select="normalize-space(substring-after(substring-after(@style,';'),'stroke:'))"/>
1.552 + <xsl:with-param name="stroke-explicit"
1.553 + select="@stroke"/>
1.554 + </xsl:call-template>
1.555 + </xsl:element>
1.556 +</xsl:template>
1.557 +
1.558 +<xsl:template name="path-main">
1.559 + <path>
1.560 + <xsl:apply-templates select="@*" />
1.561 + <!-- 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 -->
1.562 + <xsl:call-template name="make-style-attribute">
1.563 + <xsl:with-param name="fill"
1.564 + select="normalize-space(substring-after(substring-before(ancestor::*[svg:polygon]/svg:polygon[1]/@style,';'),'fill:'))"/>
1.565 + <xsl:with-param name="fill-explicit"
1.566 + select="ancestor::*[svg:polygon]/svg:polygon[1]/@fill"/>
1.567 + <xsl:with-param name="stroke"
1.568 + select="normalize-space(substring-after(substring-before(ancestor::*[svg:polygon]/svg:polygon[1]/@style,';'),'stroke:'))"/>
1.569 + <xsl:with-param name="stroke-explicit">black</xsl:with-param>
1.570 + </xsl:call-template>
1.571 + </path>
1.572 +</xsl:template>
1.573 +
1.574 +<xsl:template name="make-style-attribute">
1.575 + <xsl:param name="fill"/>
1.576 + <xsl:param name="fill-explicit"/>
1.577 + <xsl:param name="stroke"/>
1.578 + <xsl:param name="stroke-explicit"/>
1.579 + <xsl:param name="none-is-transparent" select="false()"/>
1.580 +
1.581 + <xsl:attribute name="style">
1.582 + <xsl:choose>
1.583 + <xsl:when test="$fill and (not($none-is-transparent) or $fill != 'none')">
1.584 + <xsl:call-template name="make-style-fill">
1.585 + <xsl:with-param name="fill" select="$fill"/>
1.586 + </xsl:call-template>
1.587 + </xsl:when>
1.588 + <xsl:when test="$fill-explicit and (not($none-is-transparent) or $fill-explicit != 'none')">
1.589 + <xsl:choose>
1.590 + <xsl:when test="starts-with($fill-explicit, '#')">
1.591 + <xsl:call-template name="make-style-fill">
1.592 + <xsl:with-param name="fill" select="$fill-explicit"/>
1.593 + </xsl:call-template>
1.594 + </xsl:when>
1.595 + <xsl:otherwise>fill: url(#<xsl:value-of select="$fill-explicit"/>);</xsl:otherwise>
1.596 + </xsl:choose>
1.597 + </xsl:when>
1.598 + <xsl:otherwise>fill: none;</xsl:otherwise>
1.599 + </xsl:choose>
1.600 + <xsl:choose>
1.601 + <xsl:when test="$stroke">stroke: <xsl:value-of select="$stroke"/>;</xsl:when>
1.602 + <xsl:when test="$stroke-explicit">stroke: <xsl:value-of select="$stroke-explicit"/>;</xsl:when>
1.603 + <xsl:otherwise>stroke: black;</xsl:otherwise>
1.604 + </xsl:choose>
1.605 + </xsl:attribute>
1.606 +</xsl:template>
1.607 +
1.608 +<xsl:template name="make-style-fill">
1.609 + <xsl:param name="fill"/>
1.610 + <xsl:choose>
1.611 + <xsl:when test="substring($fill,1,1) = '#'">fill: url(#fill-<xsl:value-of select="substring($fill,2,6)"/>);</xsl:when>
1.612 + <xsl:otherwise>fill: url(#<xsl:value-of select="$fill"/>);</xsl:otherwise>
1.613 + </xsl:choose>
1.614 +</xsl:template>
1.615 +
1.616 +</xsl:stylesheet>