Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 1st, 2010, 05:46 AM
Registered User
 
Join Date: Mar 2010
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
Default Compare values

Hi there!

Is it possible in xslt 1.0 compare two calculated values? For example, I've got xml:

Code:
<?xml version="1.0" standalone="yes"?>
<root>
<profile>
<name>xyz</name>
<salary>4</salary>
</profile>
<profile>
<name>mno</name>
<salary>8</salary>
</profile>
</root>
and xslt:

Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl"
version="1.0">
<xsl:template match = "/" >
<html>
<head><title></title></head>
<body>
<br />
<table border="0">
<tr>
<td class="headerClass">name</td>
<td class="headerClass">salary</td>
</tr>
<xsl:for-each select="//root/profile">
<tr>
<td><center><xsl:value-of select="name"/></center></td>
<td><center><xsl:value-of select="salary"/></center></td>
</tr>
</xsl:for-each>
<tr>
<td>Sum</td>
<td><center><xsl:value-of select="sum(/root/profile/salary)"/></center></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
so as a result I've got a table like that:

xyz 4
mno 8
Sum 12

but I wanna change some value in xml, e.g. xyz from 4 to 5, so the Sum will be 13, and compare new value with the previous one, and show an information if the value has changed, is it possible to achieve? Maybe I have to save previous value in some variable, or file?
 
Old April 1st, 2010, 06:23 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>Is it possible in xslt 1.0 compare two calculated values?

This is no way to learn a new programming language. Get yourself a good textbook (there are several offered on this site), read it, and come back if you don't understand it.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old April 1st, 2010, 06:30 AM
Registered User
 
Join Date: Mar 2010
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
Default

mhkay read all the post and then repeat, of course if you have something worth to write.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare values in different nodes fann XSLT 9 September 11th, 2008 06:25 AM
How to compare two lat/long values chandup SQL Server 2000 1 May 17th, 2007 05:07 AM
compare values in one row to the next tholleran SQL Server 2000 7 March 22nd, 2007 04:45 PM
Compare "before and after" values on a form? wayne62682 Classic ASP Basics 3 May 17th, 2006 03:13 AM
compare the values in a select box ayse1st BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 0 January 7th, 2006 03:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.