1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- Super simple XSLT to convert Nils.svg and Lars.svg to our format -->
3 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
4 <xsl:output method="text" version="1.0" encoding="UTF-8"/>
5 <xsl:template name="fill">
6 <xsl:param name="node"/>
7 <xsl:if test="count($node/@fill) > 0">
8 <xsl:text>fill: "</xsl:text>
9 <xsl:value-of select="$node/@fill"/>
10 <xsl:text>",</xsl:text>
13 <xsl:template name="stroke">
14 <xsl:param name="node"/>
15 <xsl:text>stroke: {</xsl:text>
16 <xsl:if test="count($node/@stroke) > 0">
17 <xsl:text>color: "</xsl:text>
18 <xsl:value-of select="$node/@stroke"/>
19 <xsl:text>",</xsl:text>
21 <xsl:if test="count($node/@stroke-width) > 0">
22 <xsl:text>width: "</xsl:text>
23 <xsl:value-of select="$node/@stroke-width"/>
24 <xsl:text>",</xsl:text>
26 <xsl:if test="count($node/@stroke-linecap) > 0">
27 <xsl:text>cap: "</xsl:text>
28 <xsl:value-of select="$node/@stroke-linecap"/>
29 <xsl:text>",</xsl:text>
31 <xsl:if test="count($node/@stroke-linejoin) > 0">
32 <xsl:text>join: "</xsl:text>
33 <xsl:value-of select="$node/@stroke-linejoin"/>
34 <xsl:text>",</xsl:text>
36 <xsl:text>},</xsl:text>
38 <xsl:template match="g">
39 <xsl:text>{</xsl:text>
40 <xsl:if test="count(@id) > 0">
41 <xsl:text>name: "</xsl:text>
42 <xsl:value-of select="@id"/>
43 <xsl:text>",</xsl:text>
45 <xsl:text>children: [</xsl:text>
46 <xsl:apply-templates select="g|path"/>
47 <xsl:text>]},</xsl:text>
49 <xsl:template match="path">
50 <xsl:text>{</xsl:text>
51 <xsl:if test="count(@id) > 0">
52 <xsl:text>name: "</xsl:text>
53 <xsl:value-of select="@id"/>
54 <xsl:text>",</xsl:text>
56 <xsl:text>shape: {type: "path", path: "</xsl:text>
57 <xsl:value-of select="@d"/>
58 <xsl:text>"},</xsl:text>
59 <xsl:call-template name="fill">
60 <xsl:with-param name="node" select="."/>
62 <xsl:call-template name="stroke">
63 <xsl:with-param name="node" select="."/>
65 <xsl:text>},</xsl:text>
67 <xsl:template match="svg">
68 <xsl:text>[</xsl:text>
69 <xsl:apply-templates select="g|path"/>
70 <xsl:text>]</xsl:text>