]> gitweb.michael.orlitzky.com - charm-bypass.git/blob - svgclean.xsl
COPYING: add to state the "or later" bit
[charm-bypass.git] / svgclean.xsl
1 <?xml version="1.0"?>
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 <xsl:output method="xml" encoding="UTF-8" />
6
7 <!--
8 This empty template for the xml:space attribute removes it from
9 any element where it is found. Inkscape adds it automatically, but
10 we don't rely on it, and it's been deprecated for a while:
11
12 https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xml:space
13
14 -->
15 <xsl:template match="@xml:space" />
16
17 <!--
18 This rule replaces a <tspan> directly inside of a <text> with its
19 contents. The "directly" part is important because we actually use
20 tspans in one place, for the origin -> destination. We don't want
21 to clobber THOSE tspans, but we can avoid it by putting them in a
22 group (<g>).
23 -->
24 <xsl:template match="svg:text/svg:tspan">
25 <xsl:value-of select="text()" />
26 </xsl:template>
27
28 <!--
29 Then this rule matches everything, and copies it while applying
30 any relevant templates to its children. Either we'll hit a <tspan>
31 within a <text> and process it, or we'll hit this rule again.
32 -->
33 <xsl:template match="node()|@*">
34 <xsl:copy>
35 <xsl:apply-templates select="node()|@*" />
36 </xsl:copy>
37 </xsl:template>
38 </xsl:stylesheet>