Using variables or parameters in tests
I have a problem involving the reuse of xpath tests. Unless I've used the wrong search terms, the following doesn't seem to have been discussed in the archives.
The context is a financial xslt file that outputs itemised monthly reports from an unitemised year-to-date xml file. For each item in the output file, I need to do two tests: one for date and the other for some other feature (usually party [i.e. payer/payee]). This would be an example with no parameters or variables:
<xsl:value-of select="sum(/statement/item[date >= 20050228 and party[contains('DEML')]]/amount)"/>
<xsl:variable name="actualelectricity"> <xsl:value-of select="sum(/statement/item[$datetest and $electricitytest]/amount)"/>
datetest = (date >= 20050228)
electricitytest = (party[contains('DEML')])
The reason for doing this is that it allows me to reuse the category tests (i.e. the party[contains()]-type tests) independently of the date tests: for year-to-date summaries, and for a miscellaneous class that consists of anything that is not identified by an explicit category test.
Is there a way of doing this? Nothing I've tried seems to work.
-dan -- Daniel Paul O'Donnell, PhD Associate Professor of English University of Lethbridge Lethbridge AB T1K 3M4 Tel. (403) 329-2377 Fax. (403) 382-7191 E-mail <daniel.odonnell@xxxxxxxx> Home Page <http://people.uleth.ca/~daniel.odonnell/> The Digital Medievalist Project: <http://www.digitalmedievalist.org/>
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format