[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Storing calculated values in global variables ?

Subject: RE: Storing calculated values in global variables ?
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Tue, 12 Nov 2002 09:39:05 -0000
mathematical operation in xsl
> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.