Last active
November 24, 2024 15:45
Convert Android Vector Drawable to SVG with XSLT
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="ISO-8859-1"?> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > | |
<xsl:template match="/"> | |
<svg xmlns="http://www.w3.org/2000/svg"> | |
<xsl:attribute name="width"> | |
<xsl:value-of select="substring-before(vector/@width, 'dp')"/> | |
</xsl:attribute> | |
<xsl:attribute name="height"> | |
<xsl:value-of select="substring-before(vector/@height, 'dp')"/> | |
</xsl:attribute> | |
<xsl:attribute name="viewBox"> | |
<xsl:value-of select="concat('0 0 ', vector/@viewportWidth, ' ', vector/@viewportHeight)" /> | |
</xsl:attribute> | |
<xsl:for-each select="vector/path"> | |
<path> | |
<xsl:attribute name="fill"> | |
<xsl:value-of select="@fillColor"/> | |
</xsl:attribute> | |
<xsl:attribute name="d"> | |
<xsl:value-of select="@pathData"/> | |
</xsl:attribute> | |
</path> | |
</xsl:for-each> | |
</svg> | |
</xsl:template> | |
</xsl:stylesheet> |
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
<!-- NOTE all prefixes android: were removed manually, if someone can improve xsl, you're welcome --> | |
<vector xmlns:android="http://schemas.android.com/apk/res/android" | |
width="55dp" | |
height="55dp" | |
viewportWidth="55.0" | |
viewportHeight="55.0"> | |
<path | |
pathData="M40.5,20.5l-3,0l0,6l-19.3,0l5.3,-5.3l-2.1,-2.1l-9.2,9.2l8.9,8.9l2.1,-2.1l-5.5,-5.6l22.8,0z" | |
fillColor="#ffffff" /> | |
</vector> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Related SO question.
Free online XSL Transformer