[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Setting values for variable

Subject: Re: Setting values for variable
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 10 Sep 2004 17:22:22 +0100
setting values xpath
  Thanks for the solution David, but I forget to mention
  if There is no Balance tag coming back or Balance tag value is 0, instead of 
  calculating the Payment using 2% of Balance, we will substitute it with $10


<xsl:value-of 
  select="sum(Record/Payment) +
           0.02 * sum(Record[not(Payment)]/Balance[not(.=0)) +
           10 * count(Record[not(Payment)][not(Balance) or Balance=0])"/>


Ie: just write the thing in Xpath instead of English.
It really is easier to use declarative programming instead of imperative
programming: you just have to think like a normal person and not like a
FORTRAN programmer. If describing the sum of a certain class of elements
to a person you would never use this rather strange notion of "updatable
variables" You wouldn't say start with the sum being zero and then
iterate over the class of elements incrementing the sum with a new
value, You'd just describe the final result as a function of the input
not as a series of imperative programming steps. That is the essence of
declarative programming, you just describe the desired result and leave
it up to the compiler implementors what happens at the machine level.



David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.