Dypt Recursion!
Hej,Jeg prøver og læser en d attribute i SVG path men problemet er at hvis jeg har en lang path, så får et problem "Deep recursion"? Er der en "algorithm for optimising recursion"??
her er min fil, xslt der finder komma i d path og hvis der er, den bytter den med mellemrum or "recurve" for den næste!
-------------------------------------------------------------
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes" indent="yes" />
<xsl:template match="svg">
<xsl:element name="svg">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<!-- Default transformation - identity -->
<xsl:template match="path">
<xsl:variable name="path_d" select="@d"/>
<xsl:call-template name="comma_separetor">
<xsl:with-param name="path1" select="normalize-space($path_d)"/>
<xsl:with-param name="path2" select="''"/>
</xsl:call-template>
</xsl:template>
<!--This is the template that removes any commas and replace them by comma-->
<xsl:template name="comma_separetor">
<xsl:param name="path1"/>
<xsl:param name="path2"/>
<xsl:choose>
<xsl:when test="contains($path1,' ')">
<xsl:variable name="cmd1">
<xsl:value-of select="concat(substring-before($path1,' '), ',')"/>
</xsl:variable>
<xsl:variable name="cmd2">
<xsl:value-of select="substring-after($path1, ' ')"/>
</xsl:variable>
<xsl:call-template name="comma_separetor">
<xsl:with-param name="path1" select="$cmd2"/>
<xsl:with-param name="path2" select="concat($path2,$cmd1)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:element name="path">
<xsl:attribute name="d">
<xsl:value-of select="concat($path2,$path1,',')"/>
</xsl:attribute>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
-->
