Created
April 1, 2017 15:56
-
-
Save maxkoryukov/b83af25b8d3739a698909ae648c26f93 to your computer and use it in GitHub Desktop.
Cleanup vendor tags from SVG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<xsl:stylesheet | |
version="1.0" | |
xmlns:dc="http://purl.org/dc/elements/1.1/" | |
xmlns:cc="http://creativecommons.org/ns#" | |
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | |
xmlns:svg="http://www.w3.org/2000/svg" | |
xmlns="http://www.w3.org/2000/svg" | |
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" | |
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
exclude-result-prefixes="xsl inkscape sodipodi rdf"> | |
<xsl:output method="xml" encoding="utf-8" indent="no" standalone="no"/> | |
<xsl:variable name="inkscape-ns" select="'http://www.inkscape.org/namespaces/inkscape'" /> | |
<xsl:variable name="sodipodi-ns" select="'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd'" /> | |
<xsl:variable name="preserve-style" select="false()" /><!-- TODO: use as="xs:boolean", XSLT-2 --> | |
<xsl:template match="@*"> | |
<xsl:choose> | |
<xsl:when test="namespace-uri(.)=$inkscape-ns"> | |
</xsl:when> | |
<xsl:when test="namespace-uri(.)=$sodipodi-ns"> | |
</xsl:when> | |
<xsl:when test="local-name()='style'"> | |
<xsl:if test="$preserve-style"> | |
<xsl:copy /> | |
</xsl:if> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:copy /> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template match="node()"> | |
<xsl:choose> | |
<xsl:when test="name()='metadata'"> | |
</xsl:when> | |
<xsl:when test="namespace-uri(.)=$inkscape-ns"> | |
</xsl:when> | |
<xsl:when test="namespace-uri(.)=$sodipodi-ns"> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:copy> | |
<xsl:apply-templates select="* | @*"/> | |
</xsl:copy> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment