]> gitweb.michael.orlitzky.com - charm-bypass.git/blobdiff - svgclean.xsl
svgclean.xsl: new XSL stylesheet to help clean up our inkscape mess
[charm-bypass.git] / svgclean.xsl
diff --git a/svgclean.xsl b/svgclean.xsl
new file mode 100644 (file)
index 0000000..2a1c2d2
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+               xmlns:svg="http://www.w3.org/2000/svg"
+               version="1.0">
+  <xsl:output method="xml" encoding="UTF-8" />
+
+  <!--
+    The first rule replaces a <tspan> inside of a <text> with its
+    contents.
+  -->
+  <xsl:template match="svg:text/svg:tspan">
+    <xsl:value-of select="text()" />
+  </xsl:template>
+
+  <!--
+    Then this rule matches everything, and copies it while applying
+    any relevant templates to its children. Either we'll hit a <tspan>
+    within a <text> and process it, or we'll hit this rule again.
+  -->
+  <xsl:template match="*|@*">
+    <xsl:copy>
+      <xsl:apply-templates select="*|@*" />
+    </xsl:copy>
+  </xsl:template>
+</xsl:stylesheet>