This is the first working version of my SVG to Synfig converter.
Very basic, only curved paths are converted, styles etc. are lost.
Tested with saxon (http://prdownloads.sourceforge.net/saxon/saxonb9-0-0-2j.zip) and Inkscape generated SVGs.
svg2synfig.xsl:
<!--
basic svg curves into synfig bline fills transformation
example usage (using saxon): java -jar saxon9.jar -xsl:svg2synfig.xsl your_svg_file.svg > output_file.sif
-->
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:math="http://exslt.org/math">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="/">
<canvas version="0.1">
<xsl:apply-templates select="//svg:path"/>
<layer type="zoom" active="true" version="0.1">
<param name="amount">
<real value="-6"/>
</param>
</layer>
</canvas>
</xsl:template>
<xsl:template match="svg:path">
<xsl:analyze-string select="@d" regex="M[^z]+z">
<xsl:matching-substring>
<layer type="region" active="true" version="0.1">
<param name="bline">
<bline type="bline_point" loop="true">
<xsl:call-template name="curve-path-to-bline">
<xsl:with-param name="path" select="."/>
</xsl:call-template>
</bline>
</param>
</layer>
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:template>
<xsl:template name="curve-path-to-bline">
<xsl:param name="path"/>
<xsl:analyze-string select="$path" regex="\s([0-9.]+[,\s][0-9.]+)\s[0-9.]+[,\s][0-9.]+\sz">
<xsl:matching-substring>
<xsl:analyze-string select="concat(regex-group(1), $path)" regex="([0-9.]+)[,\s]([0-9.]+)M?\s([0-9.]+)[,\s]([0-9.]+)\sC\s([0-9.]+)[,\s]([0-9.]+)">
<xsl:matching-substring>
<xsl:call-template name="node-to-bline-point">
<xsl:with-param name="c1_x" select="regex-group(1)"/>
<xsl:with-param name="c1_y" select="regex-group(2)"/>
<xsl:with-param name="x" select="regex-group(3)"/>
<xsl:with-param name="y" select="regex-group(4)"/>
<xsl:with-param name="c2_x" select="regex-group(5)"/>
<xsl:with-param name="c2_y" select="regex-group(6)"/>
</xsl:call-template>
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:template>
<xsl:template name="node-to-bline-point">
<xsl:param name="x"/>
<xsl:param name="y"/>
<xsl:param name="c1_x"/>
<xsl:param name="c1_y"/>
<xsl:param name="c2_x"/>
<xsl:param name="c2_y"/>
<xsl:variable name="mirror_y" select="- xs:float($y)"/>
<xsl:variable name="mirror_c1_y" select="- xs:float($c1_y)"/>
<xsl:variable name="mirror_c2_y" select="- xs:float($c2_y)"/>
<entry>
<composite type="bline_point">
<c1>
<vector>
<x><xsl:value-of select="$x"/></x>
<y><xsl:value-of select="$mirror_y"/></y>
</vector>
</c1>
<c2>
<real value="1"/>
</c2>
<c3>
<real value="0.5"/>
</c3>
<c4>
<bool value="true"/>
</c4>
<c5>
<xsl:call-template name="vectory-pair-to-radial">
<xsl:with-param name="origin-x" select="$c1_x"/>
<xsl:with-param name="origin-y" select="$mirror_c1_y"/>
<xsl:with-param name="x" select="$x"/>
<xsl:with-param name="y" select="$mirror_y"/>
</xsl:call-template>
</c5>
<c6>
<xsl:call-template name="vectory-pair-to-radial">
<xsl:with-param name="origin-x" select="$x"/>
<xsl:with-param name="origin-y" select="$mirror_y"/>
<xsl:with-param name="x" select="$c2_x"/>
<xsl:with-param name="y" select="$mirror_c2_y"/>
</xsl:call-template>
</c6>
</composite>
</entry>
</xsl:template>
<xsl:template name="vectory-pair-to-radial">
<xsl:param name="x"/>
<xsl:param name="y"/>
<xsl:param name="origin-x"/>
<xsl:param name="origin-y"/>
<radial_composite type="vector">
<xsl:variable name="dx" select="xs:float($x) - xs:float($origin-x)"/>
<xsl:variable name="dy" select="xs:float($y) - xs:float($origin-y)"/>
<c0>
<xsl:variable name="d_sqared" select="$dx * $dx + $dy * $dy"/>
<xsl:variable name="d">
<xsl:call-template name="math:sqrt">
<xsl:with-param name="number" select="$d_sqared"/>
</xsl:call-template>
</xsl:variable>
<real value="{$d * 3}"/>
</c0>
<c1>
<atan2 type="angle">
<x>
<real value="{$dx}"/>
</x>
<y>
<real value="{$dy}"/>
</y>
</atan2>
</c1>
</radial_composite>
</xsl:template>
<xsl:template name="math:sqrt">
<xsl:param name="number" select="0"/>
<xsl:param name="try" select="1"/>
<xsl:param name="iter" select="1"/>
<xsl:param name="maxiter" select="10"/>
<!-- This template was written by Nate Austin using Sir Isaac Newton's
method of finding roots -->
<xsl:choose>
<xsl:when test="$try * $try = $number or $iter > $maxiter">
<xsl:value-of select="$try"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="math:sqrt">
<xsl:with-param name="number" select="$number"/>
<xsl:with-param name="try" select="$try - (($try * $try - $number) div (2 * $try))"/>
<xsl:with-param name="iter" select="$iter + 1"/>
<xsl:with-param name="maxiter" select="$maxiter"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>