--- /dev/null
+<?xml version="1.0"?>\r
+<!-- http://www.exslt.org/math/functions/sqrt/math.sqrt.template.xsl -->\r
+<xsl:stylesheet version="1.0"\r
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
+ xmlns:math="http://exslt.org/math"\r
+ extension-element-prefixes="math">\r
+\r
+<xsl:template name="sqrt">\r
+ <!-- The number you want to find the square root of -->\r
+ <xsl:param name="number" select="0" /> \r
+ <!-- The current 'try'. This is used internally. -->\r
+ <xsl:param name="try" select="1" />\r
+ <!-- The current iteration, checked against maxiter to limit loop count --> \r
+ <xsl:param name="iter" select="1" />\r
+ <!-- Set this up to ensure against infinite loops -->\r
+ <xsl:param name="maxiter" select="10" />\r
+\r
+ <!-- This template was written by Nate Austin using Sir Isaac Newton's\r
+ method of finding roots -->\r
+\r
+ <xsl:choose>\r
+ <xsl:when test="$try * $try = $number or $iter > $maxiter">\r
+ <xsl:value-of select="$try"/>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:call-template name="sqrt">\r
+ <xsl:with-param name="number" select="$number"/>\r
+ <xsl:with-param name="try" \r
+ select="$try - (($try * $try - $number) div (2 * $try))"/>\r
+ <xsl:with-param name="iter" select="$iter + 1"/>\r
+ <xsl:with-param name="maxiter" select="$maxiter"/>\r
+ </xsl:call-template>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+</xsl:template>\r
+\r
+</xsl:stylesheet>\r