Subject:Using a template to sort and return a value Author:Nick Roper Date:09 Mar 2007 04:01 AM
Hi,
I'm fairly new to xslt, but have been managing to get along OK(ish) so far. However, I'm having problems trying to get my head around a certain process.
Here is the content of an example 'myfile.xml' file:
What I want to do is to assign the id of the most recently viewed product to a variable 'lastProductId'. I will need to do this at various points in the application, so the code that carries out the assignment should be stored in a separate 'widget' file that is imported into the main xslt, for example:
<xsl:import href="widgets/mywidgets.xslt" />
Then, from within the main xslt I would make the assignment as follows:
What I want to do is to return the id of the product with the highest time attribute. Not sure if I can do this by using some kind of 'max' function, or whether I need to sort the elements and the find the first (or last depending on sort order)
I've tried various approaches but can't get anything to work - any help would be very greatly appreciated.