[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Beginner's question: Mathematical Calculations in

Subject: Re: Beginner's question: Mathematical Calculations in XSL Template
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Wed, 21 Nov 2001 13:24:11 -0500
mathematical calculations
[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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.