| 1 |
<?xml version="1.0" encoding="utf-8"?> |
| 2 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 3 |
xmlns:svg="http://www.w3.org/2000/svg" |
| 4 |
version="1.0"> |
| 5 |
|
| 6 |
<!-- |
| 7 |
Transform the SVG produced by various tools, applying assorted fixups. |
| 8 |
--> |
| 9 |
|
| 10 |
<!-- |
| 11 |
Add viewBox attribute to svg element if not already present. This allows the |
| 12 |
image to scale. |
| 13 |
--> |
| 14 |
<xsl:template match="svg:svg"> |
| 15 |
<xsl:copy> |
| 16 |
<xsl:if test="not(@viewBox)"> |
| 17 |
<xsl:attribute name="viewBox"> |
| 18 |
<xsl:text>0 0 </xsl:text> |
| 19 |
<xsl:value-of select="@width"/> |
| 20 |
<xsl:text> </xsl:text> |
| 21 |
<xsl:value-of select="@height"/> |
| 22 |
</xsl:attribute> |
| 23 |
</xsl:if> |
| 24 |
<xsl:apply-templates select="@* | node()"/> |
| 25 |
</xsl:copy> |
| 26 |
</xsl:template> |
| 27 |
|
| 28 |
<!-- |
| 29 |
Fix stroke="transparent" attribute, which is invalid SVG. |
| 30 |
--> |
| 31 |
<xsl:template match="@stroke[.='transparent']"> |
| 32 |
<xsl:attribute name="stroke">none</xsl:attribute> |
| 33 |
</xsl:template> |
| 34 |
|
| 35 |
<!-- |
| 36 |
copy everything else |
| 37 |
--> |
| 38 |
<xsl:template match="@* | node()"> |
| 39 |
<xsl:copy> |
| 40 |
<xsl:apply-templates select="@* | node()"/> |
| 41 |
</xsl:copy> |
| 42 |
</xsl:template> |
| 43 |
|
| 44 |
</xsl:stylesheet> |