Subject: Re: [xsl] Beginner's question: Mathematical Calculations in XSL Template From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx> Date: Wed, 21 Nov 2001 13:24:11 -0500 |
[Ami D. Yanero] > I'm attempting to do multiplication and additon calculations in my XSL > template. I've seen several posts to various newsgroups about this same > scenario, and I've tested my calculations using the examples and > corrected answers posted. > > However, I'm getting the same error when I do the calculations with the > examples as I'm getting when I use my 'live' documents. Everything that > I've read says that what I've got should work. Please help! > First of all, you need to use an actual xslt processor as others have said. Then your example works fine (after you use the correct namespace for xslt). Here's a slightly modified version of your example and stylesheet: <?xml version = "1.0" encoding = "UTF-8"?> <numbers> <one>2</one> <two>3</two> <three>5</three> </numbers> Here is a working stylesheet and the results: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <results> <xsl:apply-templates select='numbers'/> </results> </xsl:template> <xsl:template match='numbers'> Addition:<xsl:value-of select='number(one)+number(two)+number(three)'/> Multiplication:<xsl:value-of select='number(one)*number(two)*number(three)'/> </xsl:template> </xsl:stylesheet> ============= results ============= <results> Addition:10 Multiplication:30</results> Cheers, Tom P XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Beginner's question: Math, David Carlisle | Thread | Re: [xsl] Beginner's question: Math, Ami D. Yanero |
RE: [xsl] Beginner's question: Math, Ami D. Yanero | Date | Re: [xsl] Beginner's question: Math, David Carlisle |
Month |