<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" > 
<xsl:template name="splitcurve">
<xsl:param name="patch" />
<xsl:param name="p1"  />
<xsl:param name="p2"  />
<xsl:param name="p3"  />
<xsl:param name="p4"  />
<x><xsl:value-of select="$patch/patch/x[$p1]" /></x>
<y><xsl:value-of select="$patch/patch/y[$p1]" /></y>
<z><xsl:value-of select="$patch/patch/z[$p1]" /></z>
<xsl:variable name="l2x" 
select="($patch/patch/x[$p1] + $patch/patch/x[$p2]) div 2" />
<xsl:variable name="l2y" 
select="($patch/patch/y[$p1] + $patch/patch/y[$p2]) div 2" />
<xsl:variable name="l2z" 
select="($patch/patch/z[$p1] + $patch/patch/z[$p2]) div 2" />
<xsl:variable name="hx" 
select="($patch/patch/x[$p2] + $patch/patch/x[$p3]) div 2" />
<xsl:variable name="hy" 
select="($patch/patch/y[$p2] + $patch/patch/y[$p3]) div 2" />
<xsl:variable name="hz" 
select="($patch/patch/z[$p2] + $patch/patch/z[$p3]) div 2" />
<xsl:variable name="l3x" select="($l2x + $hx) div 2" />
<xsl:variable name="l3y" select="($l2y + $hy) div 2" />
<xsl:variable name="l3z" select="($l2z + $hz) div 2" />
<xsl:variable name="r3x" 
select="($patch/patch/x[$p3] + $patch/patch/x[$p4]) div 2" />
<xsl:variable name="r3y" 
select="($patch/patch/y[$p3] + $patch/patch/y[$p4]) div 2" />
<xsl:variable name="r3z" 
select="($patch/patch/z[$p3] + $patch/patch/z[$p4]) div 2" />
<xsl:variable name="r2x" select="($r3x + $hx) div 2" />
<xsl:variable name="r2y" select="($r3y + $hy) div 2" />
<xsl:variable name="r2z" select="($r3z + $hz) div 2" />                
<xsl:variable name="l4x" select="($r2x + $l3x) div 2" />
<xsl:variable name="l4y" select="($r2y + $l3y) div 2" />
<xsl:variable name="l4z" select="($r2z + $l3z) div 2" /> 
<x><xsl:value-of select="$l2x" /></x>
<y><xsl:value-of select="$l2y" /></y>
<z><xsl:value-of select="$l2z" /></z>
<x><xsl:value-of select="$l3x" /></x>
<y><xsl:value-of select="$l3y" /></y>
<z><xsl:value-of select="$l3z" /></z>
<x><xsl:value-of select="$l4x" /></x>
<y><xsl:value-of select="$l4y" /></y>
<z><xsl:value-of select="$l4z" /></z>
<x><xsl:value-of select="$r2x" /></x>
<y><xsl:value-of select="$r2y" /></y>
<z><xsl:value-of select="$r2z" /></z>
<x><xsl:value-of select="$r3x" /></x>
<y><xsl:value-of select="$r3y" /></y>
<z><xsl:value-of select="$r3z" /></z>
<x><xsl:value-of select="$patch/patch/x[$p4]" /></x>
<y><xsl:value-of select="$patch/patch/y[$p4]" /></y>
<z><xsl:value-of select="$patch/patch/z[$p4]" /></z>
</xsl:template>
</xsl:stylesheet>

