2024-05-04 02:42:50 +02:00
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version= "2.0" xmlns:xsl= "http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/2000/svg">
<xsl:output indent= "yes" />
<xsl:template match= "/" >
<svg version= "1.0"
xmlns:xlink="http://www.w3.org/1999/xlink">
<xsl:apply-templates select= "traceur" />
</svg>
</xsl:template>
<!-- Template pour le traceur -->
<xsl:template match= "traceur" >
<xsl:variable name= "path" >
<xsl:call-template name= "generatePath" >
<xsl:with-param name= "idx" select= "1" />
2024-05-05 21:29:23 +02:00
<xsl:with-param name= "path" select= "'M 0 0 '" />
2024-05-04 02:42:50 +02:00
</xsl:call-template>
</xsl:variable>
2024-05-05 21:29:23 +02:00
<!-- TODO: usage temporaire d'un offset pour que l'image soit pas hors de
l'écran, il faut trouver à l'avenir un moyen que ça soit automatique ?? -->
<xsl:variable
name="offset" select="250" />
<g
transform="translate({$offset}, {$offset})">
<path
d="{$path}" stroke="green" fill="none" />
</g>
2024-05-04 02:42:50 +02:00
</xsl:template>
<!-- Fonction récursive terminale -->
<xsl:template name= "generatePath" >
<xsl:param name= "idx" />
<xsl:param name= "path" />
<xsl:choose >
<xsl:when test= "$idx > count(LINETO)" >
<xsl:value-of select= "$path" />
</xsl:when>
<xsl:otherwise >
<xsl:variable name= "x"
2024-05-05 21:29:23 +02:00
select="LINETO[$idx]/@x" />
2024-05-04 02:42:50 +02:00
<xsl:variable name= "y"
2024-05-05 21:29:23 +02:00
select="LINETO[$idx]/@y" />
2024-05-04 02:42:50 +02:00
<xsl:call-template name= "generatePath" >
<xsl:with-param name= "idx" select= "$idx + 1" />
<xsl:with-param name= "path" select= "concat($path, ' L ', $x, ' ', $y)" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:transform>