[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

mathematical functions - specifically sqroot

Subject: mathematical functions - specifically sqroot
From: "bix xslt" <bix_xslt@xxxxxxxxxxx>
Date: Tue, 03 Dec 2002 18:38:54 +0000
xslt mathematical functions
Attempting to resolve the following pseudo code:

N = number of children
sqrt = sqRoot(N)

if (sqrt - (int)sqrt > 0)
  w = (int)sqrt
  h = w + 1
else
  w = sqrt
  h = w


I came across the following xslt script. Is there a simpler way that I might be able to implement this? Currently, I am unable to download any additional software off the internet onto my PC. Consequently, I am also unable to get the xalan, xerces, and saxon programs. I am relying entirely on MSXML2.0 at this point as I have IE 5.0. However, I am attempting to develop for MSXML3.0 (or whichever version ships with IE 6.x) for an upgrade my group will receive in May 2003.


Thanks in advance,
Bix

<xsl:stylesheet version = "1.0
"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:MyRepeatGenerator="MyRepeatGenerator"
xmlns:MyRepeatableFunction="MyRepeatableFunction"
exclude-result-prefixes = "xsl msxsl MyRepeatGenerator MyRepeatableFunction" >


<xsl:import href = "within.xsl" />

<MyRepeatGenerator:MyRepeatGenerator/>

<MyRepeatableFunction:MyRepeatableFunction/>

        <xsl:template name = "sqrt" >
            <xsl:param name = "N" />
            <xsl:param name = "Eps" select = "0.1" />

<xsl:variable name = "vMyRepeat"
select = "document('')/*/MyRepeatGenerator:*[1]" />


<xsl:variable name = "vMyFunction"
select = "document('')/*/MyRepeatableFunction:*[1]" />


             <xsl:variable name = "vrtfParams" >
                <param>
                    <xsl:value-of select = "$N div 2" />
                </param>

<xsl:copy-of select = "$vMyFunction" />

                <param>
                    <xsl:value-of select = "$N" />
                </param>
            </xsl:variable>

<xsl:call-template name = "within" >
<xsl:with-param nam e = "pGenerator" select = "$vMyRepeat" />
<xsl:with-param name = "pParam0"
select = "msxsl:node-set($vrtfParams)/*" />
<xsl:with-param name = "Eps" select = "$Eps" />
</xsl:call-template>
</xsl:template>


        <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>

</xsl:stylesheet>


_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.