Skip to content

Instantly share code, notes, and snippets.

@ejrh
Created November 3, 2014 07:16
Show Gist options
  • Save ejrh/7b666c24067a67febeab to your computer and use it in GitHub Desktop.
Save ejrh/7b666c24067a67febeab to your computer and use it in GitHub Desktop.
XSLT for selecting only certain layers from an Inkscape SVG file.
Display the source blob
Display the rendered blob
Raw
<?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