Subject: [xsl] Re: mathematical functions - specifically sqroot From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Tue, 3 Dec 2002 14:15:44 -0800 (PST) |
--- bix xslt wrote: > 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 [template skipped -- can be found at: http://fxsl.sourceforge.net/articles/FuncProg/6.html#Square_root] Hi Bix, Let me start with the fact that MSXML2 does not implement XSLT 1.0 but a different language -- therefore the chances of it understanding any XSLT template (including templates that calculate sqrt) are close to zero. The template you listed is really more complex than it could be. It uses "generators" that may be used to do processing in a similar way to the processing of ***infinite*** lists, which is possible in languages with lazy evaluation. The same library (FXSL) contains the more generic "pow" function, which can be used to calculate sqrt (a special case when the value of pPower is 1/2). http://fxsl.sourceforge.net/articles/xslCalculator/The%20FXSL%20Calculator.html#3._The_Exponential_and_Logarithmic_Functions Or, one can use two different ways to solve the equation x^2 - a = 0 which will produce sqrt(a): http://fxsl.sourceforge.net/articles/xslCalculator/The%20FXSL%20Calculator.html#4._Solving_Equations_of_One_Real_Variable Neither of these looks particularly simple, however these templates are called in the most simple and shortest way possible. The end user need not be concerned how they work and which numerical method they implement. This said, you may find the sqrt template of Nate Austin a little bit simpler: http://sources.redhat.com/ml/xsl-list/2001-08/msg00739.html Even in this case understanding the logic requires understanding the underlying numerical method. ===== Cheers, Dimitre Novatchev. http://fxsl.sourceforge.net/ -- the home of FXSL __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Carriage Return & # 13 ;, David Carlisle | Thread | [xsl] keeping source element after , Kevin Del |
Re: [xsl] Carriage Return & # 13 ;, J.Pietschmann | Date | Re: [xsl] Element creation, David Pratt |
Month |