Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| 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 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 7th, 2005, 01:02 PM
Authorized User
 
Join Date: Dec 2003
Location: Fort Collins, CO, USA.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to btado
Default Grouping and totals

Could someone please advise on how to accomplish this task?
XML:
<Promotions>
    <Promotion Code="test" Hits="1">
        <Sale Date="6/5/2005" Amount="114.75" OrderID="31"/>
        <Sale Date="5/5/2005" Amount="60.70" OrderID="29"/>
        <Sale Date="7/5/2004" Amount="500.75" OrderID="28"/>
        <Sale Date="6/1/2005" Amount="110.00" OrderID="30"/>
        <Sale Date="6/1/2004" Amount="40.00" OrderID="32"/>
    </Promotion>
<Promotion Code="test2" Hits="15">
        <Sale Date="4/5/2005" Amount="114.75" OrderID="31"/>
        <Sale Date="1/5/2005" Amount="71.70" OrderID="29"/>
        <Sale Date="7/6/2004" Amount="45.75" OrderID="28"/>
        <Sale Date="3/1/2005" Amount="10.00" OrderID="30"/>
        <Sale Date="10/1/2004" Amount="40.00" OrderID="32"/>
    </Promotion>

</Promotions>

I need to group by month and calculate monthly totals for each code.
Any advice would be greatly appreciated!


 
Old June 9th, 2005, 09:04 AM
Authorized User
 
Join Date: Dec 2003
Location: Fort Collins, CO, USA.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to btado
Default

Please, someone respond....

 
Old June 10th, 2005, 08:00 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

First, I don't know whether your dates are in d/m/y format or m/d/y format. Choosing 10 sample dates that are all ambiguous requires skill!

Secondly, you'd be much better off using the standard ISO 8601 format yyyy-mm-dd.

You've got two problems here: parsing the dates, and then grouping by common values. For the parsing problem, you need a combination of substring-after() and substring-before(). For the grouping problem, assuming you're using XSLT 1.0, see the notes on grouping at http://www.jenitennison.com/xslt/grouping



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 22nd, 2005, 01:08 AM
Authorized User
 
Join Date: May 2005
Location: bangalore, karnataka, India.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to meetnaveen4u
Default

I think michael is right, for example u can look into this url to get the idea how to do it. http://www.biglist.com/lists/xsl-lis.../msg00200.html


Thanks &amp; Regards
Naveen.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with totals rsm42 ASP.NET 1.0 and 1.1 Basics 0 December 15th, 2006 01:18 PM
Protect cells and allow grouping/un-grouping sfreuden Excel VBA 4 December 14th, 2006 08:01 AM
Grouping and totals btado XML 4 July 1st, 2005 03:08 AM
how can i display the totals only squarefish Classic ASP Databases 4 November 9th, 2004 07:23 AM
Totals bjackman Access 1 February 8th, 2004 09:27 PM





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