I have attempted several iterations of calculating a square root of a number in XSL/XML but can't get it working. This is my latest attempt. I am getting an error "Named template 'sqrt' does not exist in the stylesheet." This is the last bit that I need to write for this stylesheet and then I can turn my project in. -TIA
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:msxsl="urn:schemas-
microsoft-com:xslt" xmlns:inr="http://mycompany.com/mynamespace">
<xsl:import href="sqrt.xsl" />
<xsl:template match="HorizontalLine | HorizontalCircle | HorizontalSpiral">
<xsl:if test="Start[@pointType = 'POB']">
SqRt:
<xsl:call-template name="sqrt">
<xsl:with-param name="value" select="100"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
The error message says that "named template 'sqrt' doesn't exist". We would expect to find it in
sqrt.xsl, but you haven't shown ussqrt.xsl, so we can infer (a) that it's not there, and (b) that you probably don't understand how import works, otherwise you would have understood the message and shown us the code.For an example of how to calculate square roots in XSLT 1.0, see http://exslt.org/math/functions/sqrt/math.sqrt.template.xsl
Two other comments:
(a) there is no XSLT version 1.1. There was a draft of 1.1 (round about 2001) but it was abandoned and never got beyond draft status.
(b) you say: "This is the last bit that I need to write for this stylesheet and then I can turn my project in". (i) This information is irrelevant to your question, and (ii) it reflects your inexperience, since an experienced programmer knows that you should never expect the bug you are currently working on to be the last one.