| Subject: [xsl] mathematical functions - specifically sqroot From: "bix xslt" <bix_xslt@xxxxxxxxxxx> Date: Tue, 03 Dec 2002 18:38:54 +0000 | 
N = number of children sqrt = sqRoot(N)
if (sqrt - (int)sqrt > 0) w = (int)sqrt h = w + 1 else w = sqrt h = w
Thanks in advance, Bix
        <xsl:template name = "sqrt" >
            <xsl:param name = "N" />
            <xsl:param name = "Eps" select = "0.1" />             <xsl:variable name = "vrtfParams" >
                <param>
                    <xsl:value-of select = "$N div 2" />
                </param>                <param>
                    <xsl:value-of select = "$N" />
                </param>
            </xsl:variable>        <xsl:template name = "myRepeater"
                     match = "*[namespace-uri()='MyRepeatGenerator']" >
            <xsl:param name = "pList" select = "/.." />
            <xsl:param name = "pParams" />            <xsl:choose>
                <xsl:when test = "not($pList)" >
                    <xsl:copy-of select = "$pParams[1]/node()" />
                </xsl:when>
                <xsl:otherwise>
                    <xsl:apply-templates select = "$pParams[2]" >
                        <xsl:with-param name = "X"
                                        select = "$pList[last()]" />
                        <xsl:with-param name = "N"
                                       select = "$pParams[3]/node()" />
                    </xsl:apply-templates>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:template>        <xsl:template name = "myRptFn"
                     match = "*[namespace-uri()='MyRepeatableFunction']" >
            <xsl:param name = "X" />
            <xsl:param name = "N" />            <xsl:value-of select = "($X + ($N div $X)) div 2" />
        </xsl:template>| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| RE: [xsl] using different templates, Michael Kay | Thread | [xsl] Element creation, David Pratt | 
| Re: [xsl] filter, Joerg Heinicke | Date | Re: [xsl] filter --much sorry for ", Paul | 
| Month |