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

Re: How can I sort values that have been calculated dy

Subject: Re: How can I sort values that have been calculated dynamically?
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Fri, 13 Jul 2001 03:58:37 -0700 (PDT)
asp sort calculated table
Bryan Tulloch wrote:


[snip]

> The problem:
> Some of the columns contain data that is not directly in the source XML but
> is computed from it (eg there is a column containing the total number of
> unique Case_Code elements for each unique User_Name).  I have a template
> matching each unique User_Name, and within this the data is being output
> into the table using this code:
> 
>      <TH>
> 	<xsl:variable name="ThisUser" select="." />
>      <xsl:value-of
> select="count(//User[./User_Name=$ThisUser][not(Case_Code=preceding::Case_Co
> de)])" />
>      </TH>
> 
>  however, I have not been able to code the column heading so that it sorts
> by this column when clicked.
> 
> Any suggestions as to how to go about this?

Hi Bryan,

In case the value to act as a sort key is difficult to express as a single
expression, then one solution is to create a new node-set which contains these
calculated values (typically as sub-elements or attributes) and then to sort this
last node-set.

This solution is both time- and space-consuming.

The better alternative is to use the generic sort() template

http://www.vbxml.com/downloads/default.asp?id=v2001611171627

which accepts as a parameter a template reference to a custom template that will
implement "comparison" between two nodes.

The comparisons that may be implemented within a custom template are not limited to
the requirement that a sort key must be expressed as a single expression.

The results of using a generic template in general and the sort() generic template
in this particular case are:

 -- increased flexibility
 -- ability to solve efficiently a larger set of problems.
 -- reduced complexity (the user produces only the custom template(s), the generic
template stays the same and is never changed.
 -- higher reusability and reliability.
 -- reduced chances for errors.
 -- considerable savings of programming time.

Cheers,
Dimitre Novatchev.

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

 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.