Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 23rd, 2006, 03:36 PM
Authorized User
 
Join Date: Jun 2006
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sum function and XPath problems

Ok, sorry for all the posts, but this is very hard for me to get for some reason. I want to sum several dozen values and present them, but the sum function is returning very small numbers, perhaps just the first number it comes to. Again, I think this is from my grouping troubles. Here is the code:
source file:
Code:
<dataroot>

<pavement_x0020_Conditions>

<BranchID>TH01PM</BranchID>
<NetworkID>PAGE</NetworkID>
<Name>PAGE MUNICIPAL AIRPORT</Name>
<Condition>100</Condition>
<Method>PCI</Method>
<DATE>2006-05-24T00:00:00</DATE>
<SAMPLES>25</SAMPLES>
<Inspected_x0020_Area>12746.297088</Inspected_x0020_Area>
<Inspected_x0020_Use>TAXIWAY</Inspected_x0020_Use>
<SectionID>20</SectionID>
<Surface>AC</Surface>

</pavement_x0020_Conditions>
Where there are hundreds of <pavement...> nodes and several different <Inspected_x0020z_Use> values.
and the xsl file:
Code:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:template match="dataroot">
<main caption="Table Title" headertextfont="Arial" headertextcolor="0xFFFFFF" rowtextfont="Arial" rowtextcolor="0x000000" headercolor="0x5372aa" rowcolor="0xFFFFFF" altrowcolor="0xcccccc">

    <xsl:for-each-group select="pavement_x0020_Conditions" group-by="Inspected_x0020_Use">
      <xsl:sort select="Inspected_x0020_Use"/>
<record>    
    <Use><xsl:value-of select="Inspected_x0020_Use"/></Use>
    <Area><xsl:value-of select="sum(current-group()/Inspected_x0020_Area)"/></Area>
</record>
</xsl:for-each-group>
</main>
</xsl:template>
</xsl:stylesheet>
I need to get the area of each Inspected Use, of which there are several types. I used a method very similar to what was suggested in my previous post, and it doesn't seem to add anything. I think I am just pointing at the wrong thing. Any ideas?
Reply With Quote
  #2 (permalink)  
Old June 26th, 2006, 10:16 AM
Authorized User
 
Join Date: Jun 2006
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Alright, I feel quite foolish. The sum function was working, but further along in the source xml document that I was processing there were some large numbers getting added in, so the numers that resulted were actually things like 10782.34005E7. Notice the "E". I tried the same thing with smaller numbers and it worked fine. Sorry to anyone who put some time into this.
Reply With Quote
  #3 (permalink)  
Old June 26th, 2006, 10:23 AM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

In XSLT 2.0, numbers in "scientific" notation are accepted.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sum and translate in XPath nwright BOOK: XSLT Programmer's Reference, 2nd Edition 2 December 5th, 2008 08:20 AM
sum() function felixm_jr Reporting Services 1 April 22nd, 2007 01:59 AM
Xpath: sum function gracehanh XSLT 13 September 27th, 2005 09:30 AM
SUM Function jmss66 Classic ASP Basics 17 July 29th, 2003 08:00 AM
Need Help with the Sum Function athanatos XSLT 1 July 22nd, 2003 10:06 AM



All times are GMT -4. The time now is 01:52 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.