Need help on using Math Functions

"Ngo, Cathy T CIV NSWCCD W. Bethesda, 2230" <[email protected]> Wed, 16 May 2007 13:33:20 -0400
Newsgroups gmane.text.xml.xslt.extensions
Message-ID <DD6D4C655407B146A4BA7891431CD0A006C29D@naeapaxrez04.nadsusea.nads.navy.mil>
Hi there,

I want to call math:sqrt(input_argument) function. If I assign value of
price is a hard code, <xsl:variable name="price" select="25" />, and
<xsl:variable name="sqrtOfPrice" select="math:sqrt($price)" /> , I don't
have any problem; However, if I define the price represents a value of a
node set, like <xsl:variable name="price"
select="catalog/cd/price[position()=1]" /> , then the
math:sqrt(input_argument) function can not recognize the value of price.
The error that I got as "Microsoft JScript runtime error Wrong number of
arguments or invalid property assignment line = 2, col = 20 (line is
offset ...". I tried to call math function at xsl:stylesheet section and
at xsl:template section. I still don't have any luck Please, some body
help me.

Below are my sample codes to call math:sqrt() function.

<!--cdcatalog.xml-->
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited with XML Spy v2007 (http://www.altova.com) -->
<?xml-stylesheet type="text/xsl" href="cdcatalog_stylesheet.xsl"?>
<catalog>
	<cd>
		<title>Empire Burlesque</title>
		<artist>Bob Dylan</artist>
		<country>USA</country>
		<company>Columbia</company>
		<price>10.90</price>
		<year>1985</year>
	</cd>
	<cd>
		<title>Hide your heart</title>
		<artist>Bonnie Tyler</artist>
		<country>UK</country>
		<company>CBS Records</company>
		<price>9.90</price>
		<year>1988</year>
	</cd>
</catalog>

<!--cdcatalog_stylesheet.xsl-->
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited with XML Spy v2007 (http://www.altova.com) -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:math="http://exslt.org/math" extension-element-prefixes="math" >
<xsl:import href="math/functions/sqrt/math.sqrt.msxsl.xsl" />
<xsl:variable name="price" select="catalog/cd/price[position()=1]" />
<!--
<xsl:variable name="value" select="math:sqrt($price)" />
-->
<xsl:template match="/">
  <html>
  <body>
    <h2>My CD Collection</h2>
    <table border="1">
      <tr bgcolor="#9acd32">
        <th>Title</th>
        <th>Artist</th>
        <th>Price</th>
        <th>SqrtOfPrice</th>
     </tr>
      <xsl:for-each select="catalog/cd">
      <xsl:sort select="artist" />10:51 AM 5/14/2007
      <tr>
        <td><xsl:value-of select="title"/></td>
        <td><xsl:value-of select="artist"/></td>
        <td><xsl:value-of select="$price"/></td>
        <td><xsl:value-of select="math:sqrt($price)"/></td>
      </tr>
      </xsl:for-each>
    </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>

_______________________________________________
exslt mailing list
[email protected]
http://www.exslt.org/list