473,624 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

addition with xsl fo

178 New Member
Hi,

Im a little out of my depth using xsl fo here. I have a table of items and each has a price in the second row of the table. I need to display a total at the bottom of the row. My problem is that I can't work out how to perform addition in xsl fo.

Here's my xsl file where I have created the table.
Expand|Select|Wrap|Line Numbers
  1. <!-- Nextpage: Quote -->
  2.                <fo:block break-before="page" space-before="2in" space-after="2in">
  3.  
  4.                  <fo:block text-align="center" space-before="2cm">
  5.                 Panels
  6.                 </fo:block>
  7.                 <fo:table space-before="1cm">
  8.                   <fo:table-body>
  9.                   <xsl:for-each select="quote/panels/panel">
  10.                         <fo:table-row>
  11.                       <fo:table-cell padding="6pt">
  12.                         <fo:block text-align="start"><xsl:value-of select="panel_name"/></fo:block>
  13.                       </fo:table-cell>
  14.                       <fo:table-cell padding="6pt">
  15.                         <fo:block text-align="end" space-after="2cm">£<xsl:value-of select="totalcost"/></fo:block>
  16.                       </fo:table-cell>
  17.                     </fo:table-row>
  18.                     </xsl:for-each>
  19.                     <fo:table-row>
  20.                         <fo:table-cell>
  21.                             <fo:block text-align="start" font-weight="bold" border-top="0.5pt solid red">Sub Total</fo:block>
  22.                         </fo:table-cell>
  23.                         <fo:table-cell>
  24.                             <fo:block font-weight="bold" text-align="end" border-top="0.5pt solid red"></fo:block>
  25.                         </fo:table-cell>
  26.                         </fo:table-row>
  27.                         </fo:table-body>
  28.                 </fo:table>
I need to add all the <xsl:value-of select="totalco st"/> values to get the total

Thanks in advance
Dec 17 '08 #1
5 5105
Dormilich
8,658 Recognized Expert Moderator Expert
@cleary1981
XSL-FO is for layouting. use XSL for the computation (esp. the XPath functions (e.g. sum()))) .

regards
Dec 17 '08 #2
cleary1981
178 New Member
could you show me how?
Dec 17 '08 #3
Dormilich
8,658 Recognized Expert Moderator Expert
Expand|Select|Wrap|Line Numbers
  1. <xsl:value-of select="sum(quote/panels/panel/totalcost)"/>
(didn't try it, but that's the syntax)
Dec 17 '08 #4
cleary1981
178 New Member
Yeah that is exactly what I was looking for. I just add that into my code like so

Expand|Select|Wrap|Line Numbers
  1. <!-- Nextpage: Quote -->
  2.                <fo:block break-before="page" space-before="2in" space-after="2in">
  3.  
  4.                  <fo:block text-align="center" space-before="2cm">
  5.                 Panels
  6.                 </fo:block>
  7.                 <fo:table space-before="1cm">
  8.                   <fo:table-body>
  9.                   <xsl:for-each select="quote/panels/panel">
  10.                         <fo:table-row>
  11.                       <fo:table-cell padding="6pt">
  12.                         <fo:block text-align="start"><xsl:value-of select="panel_name"/></fo:block>
  13.                       </fo:table-cell>
  14.                       <fo:table-cell padding="6pt">
  15.                         <fo:block text-align="end" space-after="2cm">£<xsl:value-of select="totalcost"/></fo:block>
  16.                       </fo:table-cell>
  17.                     </fo:table-row>
  18.                     </xsl:for-each>
  19.                     <fo:table-row>
  20.                         <fo:table-cell>
  21.                             <fo:block text-align="start" font-weight="bold" border-top="0.5pt solid red">Sub Total</fo:block>
  22.                         </fo:table-cell>
  23.                         <fo:table-cell>
  24.                             <fo:block font-weight="bold" text-align="end" border-top="0.5pt solid red"><xsl:value-of select="sum(quote/panels/panel/totalcost)"/></fo:block>
  25.                         </fo:table-cell>
  26.                         </fo:table-row>
  27.                         </fo:table-body>
  28.                 </fo:table>
Dec 17 '08 #5
Dormilich
8,658 Recognized Expert Moderator Expert
bear in mind that the XPath I used is a guess (though I hope a good one).
Dec 17 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3428
by: Mark Dickinson | last post by:
Can anyone either reproduce or explain the following apparently inconsistent behaviours of __add__ and __mul__? The class Gaussian provides a sub-bare-bones implementation of Gaussian integers (a Gaussian integer is a complex number x+yi for which both x and y are integers): class Gaussian(object): """class representing Gaussian integers"""
7
7686
by: jeffbernstein | last post by:
Greetings. I'm reading "How to think like a computer scientist: Learning with Python" and there's a question regarding string operations. The question is, "Can you think of a property that addition and multiplication have that string concatenation and repetition do not?" I thought it was the commutative property but "<string>"*3 is equivalent to 3*"<string>". Any ideas?
3
5216
by: Jay | last post by:
I have two strings that instead of adding them together to get the sum the are concatenating together. Does anyone know how I can get these two to add. while not rstemp4.eof vservdate = rstemp4("servdate") vdesc = rstemp4("desc") vservhours2 = rstemp4("servhours") vtravelhours = rstemp4("travelhours") vtech = rstemp4("tech")
2
1622
by: akickdoe22 | last post by:
i could really use help finishing this addition program. I'm stuck on the part that allows you to add any two large integers,up to 100 digits,(pos+pos, neg+neg, and pos+neg). could use hints ideas code anything for neg+pos addition. CODE SO FAR: class INT { int digits; char sign; public:
24
2702
by: Alex Vinokur | last post by:
Consider the following statement: n+i, where i = 1 or 0. Is there more fast method for computing n+i than direct computing that sum? -- Alex Vinokur email: alex DOT vinokur AT gmail DOT com http://mathforum.org/library/view/10978.html
34
16659
by: Andy | last post by:
Hi, Are 1 through 4 defined behaviors in C? unsigned short i; unsigned long li; /* 32-bit wide */ 1. i = 65535 + 3; 2. i = 1 - 3; 3. li = (unsigned long)0xFFFFFFFF + 3; 4. li = 1 - 3;
3
2180
by: snow.carriers | last post by:
Let me first state that I'm using Borland Turbo C++, it's relatively old so the new string methods won't work. Anyways, first I'm trying to collect a line of a string (with numbers, letters, dashes) into each variable. For just numbers, it's relatively easy: ifstream fout("s1.in"); for (a=0; a<17; a++) { fout >> data; cout << data << endl; }
5
4588
by: Mike | last post by:
Hello All, Please, if anyone can point me to the problem, I'd sure appreciate it! I am very new to VB programming and not a programmer to begin with. This is part of a Visual Basic 2005 Express Edition program to control a remote basketball scoreboard display unit. All I'm trying to do is add 5 byte variables and store the result in an integer variable. I added a Try/Catch block to take look at things. This exception occurs only when...
5
2271
by: Paul | last post by:
Why is the addition here adding the number as a string but the subtraction works fine? function boxchange(box) { iv= dbform.ut.value if (box.checked == true) { iv = iv - box.value } else { iv = iv + box.value
3
1602
by: srinivas33034 | last post by:
Hi there, my problem is i have to perform addition dyamically My req is i have 3 txt boxes.. and another text box to display total additon.. as i am entering the values in TextBox1 i want to see the updated addition performed so far in the final textbox..
0
8249
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8179
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8685
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2613
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.