]> gitweb.michael.orlitzky.com - charm-bypass.git/blobdiff - svgclean.xsl
COPYING: add to state the "or later" bit
[charm-bypass.git] / svgclean.xsl
index 2a1c2d21f809b13e5da9a63d60c6466a8920ae70..8d48cd0851a2e6ae8add988ce0ca59421f0a2b05 100644 (file)
@@ -5,8 +5,21 @@
   <xsl:output method="xml" encoding="UTF-8" />
 
   <!--
-    The first rule replaces a <tspan> inside of a <text> with its
-    contents.
+    This empty template for the xml:space attribute removes it from
+    any element where it is found. Inkscape adds it automatically, but
+    we don't rely on it, and it's been deprecated for a while:
+
+      https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xml:space
+
+  -->
+  <xsl:template match="@xml:space" />
+
+  <!--
+    This rule replaces a <tspan> directly inside of a <text> with its
+    contents. The "directly" part is important because we actually use
+    tspans in one place, for the origin -> destination. We don't want
+    to clobber THOSE tspans, but we can avoid it by putting them in a
+    group (<g>).
   -->
   <xsl:template match="svg:text/svg:tspan">
     <xsl:value-of select="text()" />
@@ -17,9 +30,9 @@
     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:template match="node()|@*">
     <xsl:copy>
-      <xsl:apply-templates select="*|@*" />
+      <xsl:apply-templates select="node()|@*" />
     </xsl:copy>
   </xsl:template>
 </xsl:stylesheet>