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 Display Modes
  #11 (permalink)  
Old March 25th, 2007, 07:32 PM
mhkay's Avatar
Wrox Author
Points: 18,155, Level: 58
Points: 18,155, Level: 58 Points: 18,155, Level: 58 Points: 18,155, Level: 58
Activity: 75%
Activity: 75% Activity: 75% Activity: 75%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,914
Thanks: 0
Thanked 277 Times in 272 Posts
Default

I don't know anything about your application architecture: you mention XSLT transformations, JSP, javascript, and user interaction, but I have no idea how all these things fit together. That makes it quite impossible to answer your question.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #12 (permalink)  
Old March 26th, 2007, 03:08 AM
Registered User
 
Join Date: Oct 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Sorry for given a trouble to you.
  I would like to show the clear problem now

<root>
  <profile>
     <name>xyz<name>
     <salary>40000<salary>
     <addr>abc</addr>
 </profile>
 <profile>
    <name>mno<name
    <salary>50000<salary>
    <addr>def</addr>
  </profile>
</root>


 Using <xsl:value-of select="sum(root/profile/salary)"/> i can able to print total salaries in JSP.

 We have one submit button in that page. When the user clicks that button it will ask the confirmation "You are about to submit with a total payments of xxxx" by the onclick. Here xxxxx is the total of the salaries using (<xsl:value-of select="sum(root/profile/salary)"/>)

<a href="javascript:Click('/XMLFileUpload.do');" onclick="javascript:return confirmation(xxxx);"
                    title="Click to send to HMRC"><img src="sendtoHMRC.jpg" /> </a>



The total salaries is able to print in the JSP. I need to store that salary and pass as a argument to the java-script method invoked by onclick

<script>
function confirmation( xxxxx ){

if(!confirm(" You are about to submit with a total payments of"+ xxxx))
   return false;
     return true;
}

</script>






Reply With Quote
  #13 (permalink)  
Old March 26th, 2007, 03:42 AM
Registered User
 
Join Date: Jan 2007
Location: Reading, , United Kingdom.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use an attribute value template..

<xsl:variable name="total" select="sum(/root/profile/salary)" />
<a onclick="return confirmation({$total});"
...
...


Reply With Quote
  #14 (permalink)  
Old April 16th, 2014, 03:51 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default trying to sum and count the values

Hi Everyone. I am trying to get a total of the credits in one course. My xml file is :
<Handbook>
<courses>
<course_code></course_code>
<course_title></course_title>

<c_structure>
<course_info>
<year>1</year>
<semester>1</semester>

<units>
<unit>
<unit_code></unit_code>
<unit_title></unit_title>
<credit_points></credit_points>
</unit>

<unit>
<unit_code></unit_code>
<unit_title></unit_title>
<credit_points></credit_points>
</unit>
</units>
</course_info>


<course_info>
<year>1</year>
<semester>2</semester>

<units>
<unit>
<unit_code></unit_code>
<unit_title></unit_title>
<credit_points></credit_points>
</unit>

<unit>
<unit_code></unit_code>
<unit_title></unit_title>
<credit_points></credit_points>
</unit>
</units>
</course_info>

</c_structure>
</courses>
</Handbook>

and then another course starts

this is my xslt code to show the total number of credits of each course:
<h2><u>Student Results</u></h2>
xsl:for-each select="Handbook/courses[course_title=$sid]">

<strong>Course: </strong><xsl:value-of select="course_code"/><xsl:text>
</xsl:text><xsl:value-of select="course_title"/>

<Strong>Total CP: </strong><xsl:value-of select="sum(Handbook/c_structure/course_info/units/unit/credit_points)+(count(Handbook/c_structure/course_info/units/unit/credit_points))"/>


</xsl:for-each> <!-- This closes the Handbook for each loop -->

Because there are multiple courses in the handbook, so im trying to get the total credits of each courses summing up all the semester, say for example one course has three years with two semesters in each year, and there are multiple units in each semester. hope im not making it complex.
any help will be appericiated. as i am stuck at this point.


Thnks
Reply With Quote
  #15 (permalink)  
Old April 16th, 2014, 04:30 AM
mhkay's Avatar
Wrox Author
Points: 18,155, Level: 58
Points: 18,155, Level: 58 Points: 18,155, Level: 58 Points: 18,155, Level: 58
Activity: 75%
Activity: 75% Activity: 75% Activity: 75%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,914
Thanks: 0
Thanked 277 Times in 272 Posts
Default

Please start a new thread for a new question rather than tagging onto a thread that was closed 7 years ago. And please say whether you are using XSLT 1.0 or 2.0.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
  #16 (permalink)  
Old February 7th, 2017, 10:49 AM
Registered User
Points: 20, Level: 1
Points: 20, Level: 1 Points: 20, Level: 1 Points: 20, Level: 1
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Feb 2017
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi,

<cac:InvoiceLine>
<cac:AllowanceCharge>
<cbc:SequenceNumeric>1</cbc:SequenceNumeric>
<cbc:Amount currencyID="TRY">2.00</cbc:Amount>
</cac:AllowanceCharge>
<cac:AllowanceCharge>
<cbc:SequenceNumeric>2</cbc:SequenceNumeric>
<cbc:Amount currencyID="TRY">3.00</cbc:Amount>
</cac:AllowanceCharge>
</cac:InvoiceLine>
<cac:InvoiceLine>
<cac:AllowanceCharge>
<cbc:SequenceNumeric>1</cbc:SequenceNumeric>
<cbc:Amount currencyID="TRY">4.00</cbc:Amount>
</cac:AllowanceCharge>
<cac:AllowanceCharge>
<cbc:SequenceNumeric>2</cbc:SequenceNumeric>
<cbc:Amount currencyID="TRY">5.00</cbc:Amount>
</cac:AllowanceCharge>
</cac:InvoiceLine>

xslt version 2.0

i want
if "SequenceNumeric=1" sum(cbc:Amount)
if "SequenceNumeric=2" sum(cbc:Amount)

how make this formul.

Thank you

Quote:
Originally Posted by mhkay View Post
The function sum() expects a node-set as its argument. You are supplying a single node (.), so sum() returns the numeric value of that node. You are then doing a string-concatenation of the results of several calls on the sum function.

You want <xsl:value-of select="sum(root/profile/salary)"/>



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #17 (permalink)  
Old February 7th, 2017, 11:28 AM
mhkay's Avatar
Wrox Author
Points: 18,155, Level: 58
Points: 18,155, Level: 58 Points: 18,155, Level: 58 Points: 18,155, Level: 58
Activity: 75%
Activity: 75% Activity: 75% Activity: 75%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,914
Thanks: 0
Thanked 277 Times in 272 Posts
Default

Sorry, but you are going to have to find a way to explain your requirements more clearly. Which SequenceNumeric? Which cbc:Amount? If you can't describe the logic, at least show what answer you expect for this input.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
  #18 (permalink)  
Old February 7th, 2017, 11:35 AM
Registered User
Points: 20, Level: 1
Points: 20, Level: 1 Points: 20, Level: 1 Points: 20, Level: 1
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Feb 2017
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Sorry, i want if SequenceNumeric value 1 total sum Amount



Quote:
Originally Posted by mhkay View Post
Sorry, but you are going to have to find a way to explain your requirements more clearly. Which SequenceNumeric? Which cbc:Amount? If you can't describe the logic, at least show what answer you expect for this input.
Reply With Quote
  #19 (permalink)  
Old February 8th, 2017, 02:52 AM
Registered User
Points: 20, Level: 1
Points: 20, Level: 1 Points: 20, Level: 1 Points: 20, Level: 1
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Feb 2017
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Default

My aim is to collect the Amounts of those who have SequenceNumeric value 1

Quote:
Originally Posted by yozsubasi View Post
Sorry, i want if SequenceNumeric value 1 total sum Amount
Reply With Quote
  #20 (permalink)  
Old February 8th, 2017, 06:14 AM
mhkay's Avatar
Wrox Author
Points: 18,155, Level: 58
Points: 18,155, Level: 58 Points: 18,155, Level: 58 Points: 18,155, Level: 58
Activity: 75%
Activity: 75% Activity: 75% Activity: 75%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,914
Thanks: 0
Thanked 277 Times in 272 Posts
Default

That's a bit clearer (I hope). It sounds as if you want

Code:
sum(//cac:AllowanceCharge[cbc:SequenceNumeric='1']/cbc:Amount)
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
The Following User Says Thank You to mhkay For This Useful Post:
yozsubasi (February 8th, 2017)
Reply


Thread Tools
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
xslt adding text blitzer XSLT 3 May 19th, 2007 11:10 PM
xslt adding image palli2004 XSLT 2 December 30th, 2006 06:35 PM
adding elements in XSLT 1.0 spencer.clark XSLT 3 July 25th, 2005 10:41 AM
Adding Values NeilS21 Beginning VB 6 1 February 6th, 2004 10:45 AM



All times are GMT -4. The time now is 01:15 AM.


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