• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to sum from 2 fields?

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's my xml



I want to sum the total sale prices, in this case it will be $14 because the 1st one does not sell any ticket

The simplest way I think of is to multiple price with sold for each ticket and then sum it all up.

I group by <ticket> and below is my code but I got 0

<?sum(current-group()/sold * current-group()/price)?>

Do you know why? If you have a simpler approach, please let me know

Thanks
 
Ong Vua
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more thing, the <sold></sold> tag will only have 2 values (1 or 0)
 
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

<?sum(current-group()/sold * current-group()/price)?>


What is it? Where do you learn this syntax, remotely like a processing-instruction but not being one?

I group by <ticket>


Suppose you mean what you say and thereby you mean you're working with xslt 2.0 as well.

One more thing, the <sold></sold> tag will only have 2 values (1 or 0)


If you do thing right, it does not generically matter.

Here is how at the current-group() (xslt 2.0) of what you said you have grouped.
reply
    Bookmark Topic Watch Topic
  • New Topic