473,378 Members | 1,444 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Xslt sum of absolute values

Hi

I'm trying to calculate sum of absolute values using Xslt 1.0
and math:abs (http://www.exslt.org/math/functions/abs/index.html)

I thought this would work:
<xsl:value-of select="sum(math:abs(/A/B/C))"/>
Well it doesn't, because there are multiple C's.

Is there any nice trick how to do this, or do I have to use
for-each -loop?

Thanks in advance

--
// Juho Jussila
\X/
Nov 12 '07 #1
3 4077
Juho Jussila wrote:
Hi

I'm trying to calculate sum of absolute values using Xslt 1.0
and math:abs (http://www.exslt.org/math/functions/abs/index.html)

I thought this would work:
<xsl:value-of select="sum(math:abs(/A/B/C))"/>
Well it doesn't, because there are multiple C's.

Is there any nice trick how to do this, or do I have to use
for-each -loop?

Thanks in advance
sum(/A/B/C[. &gt; 0]) - sum(/A/B/C[. &lt; 0])

David

--
http://dpcarlisle.blogspot.com
Nov 12 '07 #2

David Carlisle <da********@dcarlisle.demon.co.ukwrote in
<fh*******************@news.demon.co.uk>:
Juho Jussila wrote:
>I'm trying to calculate sum of absolute values using Xslt
1.0 and math:abs
(http://www.exslt.org/math/functions/abs/index.html)

I thought this would work:
<xsl:value-of select="sum(math:abs(/A/B/C))"/>
Well it doesn't, because there are multiple C's.

Is there any nice trick how to do this, or do I have to
use for-each -loop?

sum(/A/B/C[. &gt; 0]) - sum(/A/B/C[. &lt; 0])
Ah, cuspy.

--
....also, I submit that we all must honourably commit seppuku
right now rather than serve the Dark Side by producing the
HTML 5 spec.
Nov 13 '07 #3
David Carlisle <da********@dcarlisle.demon.co.ukwrites:
sum(/A/B/C[. &gt; 0]) - sum(/A/B/C[. &lt; 0])
Nice solution, thanks.

--
// Juho Jussila
\X/ 050 358 0895
Nov 13 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Vincent Lefevre | last post by:
I would like to know if the base URI considered to resolve an unparsed entity defined by a relative URI should be the URI before or after its rewriting due to a possible catalog. Let's take an...
2
by: Jon Martin Solaas | last post by:
For java programmers there exist a framework called Millstone (www.millstone.org) for programming web user-interfaces in a component oriented way. Millstone uses xslt transformations to render...
2
by: FrankStallone | last post by:
I am just getting started in XML and I made my first xml, dtd and xslt file and XML spy said they were all valid and they worked. This was the xslt doc that worked. <?xml version="1.0"...
4
by: Asbjørn Ulsberg | last post by:
Sorry for posting to a lot of groups, but I'm not sure what this problem relates to, so I thought it was better to be safe than sorry. Please feel free to set FUT to the proper group when...
0
by: Christopher M. Lauer | last post by:
I have done my best to answer this question but can not find the proper set of commands. I would like to transform an xml file (in code behind) and display its output in a specific html tag,...
4
by: David S. Alexander | last post by:
How can I do simple subtraction in an XSLT. I want to read a few attribute values from an XML document, calculate their difference, and transform that value to an attribute in the XML output...
4
by: Hoi Wong | last post by:
I have an XSLT script collection that converts messed up XML to usuable XML. Instead of generic template matching, I want to establish a context node for some branches so that I don't have to rely...
8
by: manugm1987 | last post by:
<?xml-stylesheet type="text/xsl" href="ch1.xsl"?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <style type="text/css"> span.cls_002{...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.