Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 23rd, 2006, 03:36 PM
Authorized User
 
Join Date: Jun 2006
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?
 
Old June 26th, 2006, 10:16 AM
Authorized User
 
Join Date: Jun 2006
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.
 
Old June 26th, 2006, 10:23 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 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





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.