Created
November 3, 2014 07:16
-
-
Save ejrh/7b666c24067a67febeab to your computer and use it in GitHub Desktop.
XSLT for selecting only certain layers from an Inkscape SVG file.
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:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:svg="http://www.w3.org/2000/svg" | |
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" | |
> | |
<xsl:param name="layer"/> | |
<xsl:template match="@*|node()"> | |
<xsl:copy> | |
<xsl:apply-templates select="@*|node()"/> | |
</xsl:copy> | |
</xsl:template> | |
<xsl:template match="svg:g[@inkscape:label]"> | |
<xsl:if test="@inkscape:label = 'base' or @inkscape:label = $layer"> | |
<xsl:copy> | |
<xsl:apply-templates select="@*|node()"/> | |
</xsl:copy> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template match="svg:g/@style[../@inkscape:label]"> | |
<xsl:attribute name="svg:style">display:inline</xsl:attribute> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment