Subject: [xsl] 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) |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] variable match attribute, Bedwell Tom | Thread | [xsl] Newbie XSL Advice, Hewko, Doug |
RE: [xsl] Generating a Table of Con, ghostrider | Date | [xsl] Newbie XSL Advice, Hewko, Doug |
Month |