Wrox Programmer Forums
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 22nd, 2005, 06:48 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 290
Thanks: 24
Thanked 0 Times in 0 Posts
Default

Hi Michael,

you worte:

"If you can translate the data to something that talks about real semantic objects (employees, prices, and bicycles, not rows, cells and values) it will become much clearer what you are trying to do."

I will try explain what I need to sort. I have attempted to produce a grid below which is similar to the output I am currently getting. I have 4 columns: Total, All Users (people who said yes to a survey question), Non Users (people who said no to a survey question), Solus Users (people who only use a particular brand).

Then I have the rows such as ************ and Age. Please disregard Rows since this is only a test. Within each row we have in this case information about demographics.

So for each column we have a corresponding <DataValue> element which contain the value for the row/column relatinship. If we take the Total column and Age row, we will see that the last row reads:
          Total
65+ 9066.51

Even though this is the highest number it is displayed last. I would like to be able to sort it so that the highest number of each row starts first (Descenging order).

Please note that in this case we are talking about the Total column.

Now, suppose the users want the rows of the All Users column to be sorted. This row would have to the first since it has the highest number:
          Total All USers
35-44 8527.03 5952

However, in the normal layout it is the 3rd row. And then I would like to be able to apply the same principle for the Non Users / Solus Users columns.

Is this possible to do ??

This is the current layout:


                Total All Users Non Users Solus Users
Rows
      Total 46685 30119.2 16565.8 9269.81
************
      All Men 22753 13989.2 8763.77 4596.47
      All Women 23932 16130 7802.02 4673.34
Age
      15-24 6954.27 2989.77 3964.5 852.762
      25-34 8662.48 5728.38 2934.1 1597.11
      35-44 8527.03 5952.29 2574.74 1812.4
      45-54 7593.98 5680.51 1913.46 1727.01
      55-64 5880.71 4107.67 1773.04 1373.49
      65+ 9066.51 5660.57 3405.95 1907.04

If I sort by All Users, this should be the result:

                Total All Users Non Users Solus Users
Rows
      Total 46685 30119.2 16565.8 9269.81
************
      All Men 22753 13989.2 8763.77 4596.47
      All Women 23932 16130 7802.02 4673.34
Age
      35-44 8527.03 5952.29 2574.74 1812.4
      25-34 8662.48 5728.38 2934.1 1597.11
      45-54 7593.98 5680.51 1913.46 1727.01
      65+ 9066.51 5660.57 3405.95 1907.04
      55-64 5880.71 4107.67 1773.04 1373.49
      15-24 6954.27 2989.77 3964.5 852.762

I hope it is a bit more clear what I have to do and I would appreciate your help.

Cheers,

Claudio

 
Old February 23rd, 2005, 06:05 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 290
Thanks: 24
Thanked 0 Times in 0 Posts
Default

Hi Michael,

I am sorry but I think my explanation is not clear again since I have had no replies and I do not know how to make it clearer. I just wish there was a way to sort by the <DataValue> tag.

Cheers,

Claudio

 
Old February 25th, 2005, 11:27 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 290
Thanks: 24
Thanked 0 Times in 0 Posts
Default

Michael,

FOOD FOR THOUGHT:

I understand when you say that this xml document (schema) is one that captures no semantics, however, some people see the use of terms like Variable and Value as being semantic, albeit related to our industry. These are common terms describing data in statistical circles. This is equivalent to things like Prices etc.

Furthermore, the current schema prevents unnecessary repetition of information: the table structure, particularly, columns/rows. There isn't a way to do this without repetition of information.

However, I am stuck and have not been able to sort by data values !!

I am looking at your suggestion to use several phases executing within a single stylesheet but I am finding hard to figure out how to do that. I am not sure where to create the variable in my xslt document and how to populate it with the current output and then how to sort in the second phase.

"""
The general pattern is:

<xsl:variable name="temp1">
  <xsl:apply-templates select="/" mode="phase1"/>
</xsl:variable>

<xsl:template match="/">
  <xsl:apply-templates select="exslt:node-set($temp1)" mode="phase2"/>
</xsl:template>
"""

Cheers,

Claudio

 
Old February 25th, 2005, 11:54 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I'm sorry, I've tried to point you in the right direction, but I simply don't have time to take you to the destination step by step.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic sort order or sort datatype kapy_kal XSLT 2 September 18th, 2007 02:10 PM
how to sort cross tab.sort based on row total joxa83 Crystal Reports 7 March 2nd, 2006 09:12 AM
Sort @* sheila XSLT 2 July 17th, 2005 04:01 PM
Unable to sort using xsl sort command sly_jimmy_boy XSLT 3 June 17th, 2005 05:15 AM
sort by question elladi Classic ASP Databases 1 March 29th, 2005 11:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.