[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Storing calculated values in global variables ?
> 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
|
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
|