|
Subject: RE: [xsl] Storing calculated values in global variables ? From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Tue, 12 Nov 2002 09:39:05 -0000 |
> I can sort the elements from both the documents in ascending
> or descending order and extract the maximum and minimum value
> elements using a single stylesheet. But how do I perform
> mathematical operations on the sorted elements ? For e.g if I
> want to add the first and the last <From> element from the
> sorted list of <From> elements how can I do this and store
> this value in a global variable so that it can be reused ?
>
You capture the sorted lists in result tree fragments and then use the
xx:node-set() extension function to access these as if they were source
documents:
<xsl:variable name="sorted-list-1">
<xsl:for-each select="document('a.xml')/record">
<xsl:sort select="key"/>
<xsl:copy-of select="."/>
</
</
<xsl:variable name="sorted-list-2">
.. ditto ..
</
<xsl:variable name="sum-of-first-and-last"
select="xx:node-set($sorted-list-1)/record[1] +
xx:node-set($sorted-list-1)/record[last()]"/>
Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Storing calculated values in , Chitra Lalita Madhwa | Thread | [xsl] wierd textarea behaviour with, Declan Brennan |
| RE: [xsl] Calculation of Minimum o, Michael Kay | Date | RE: [xsl] Using Javascript with XSL, Michael Kay |
| Month |