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

RE: Vertical table display with sort

Subject: RE: Vertical table display with sort
From: Sundar Shanmugasundaram <SSHANMUGASUNDARAM@xxxxxxxxxxxxx>
Date: Wed, 30 Apr 2003 15:02:18 +0530
vertical table
<snip>
<xsl:for-each select="o/com/hereyougo/*">
</snip>

You can't explicitly say the element name
hereyougo is the element name. If you go thro the
xml file, it can be different element for the next pair.


<?xml version="1.0"?>
<o>
	<com>
		<hereyougo>
			<first displayposition="4"
displayname="raman4">4</first>
			<second displayposition="1"
displayname="raman1">1</second>
			<third displayposition="3"
displayname="raman3">3</third>		
			<fourth displayposition="2"
displayname="raman2">2</fourth>
		</hereyougo>
		<imaycome>
			<four displayposition="4"
displayname="raman4">22</four>
			<five displayposition="1"
displayname="raman1">33</five>
			<six displayposition="3"
displayname="raman3">44</six>			
			<firvi displayposition="2"
displayname="raman2">11</firvi>			
		</imaycome>
	</com>
</o>


is the xml file.

-----Original Message-----
From: Zink, Juergen [mailto:Juergen.Zink@xxxxxxxxxxxxxxxxxxxx]
Sent: Wednesday, April 30, 2003 2:40 PM
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject: AW:  Vertical table display with sort
Importance: Low


Hi,

<snip>
I would like to sort the following XML file based on the displayposition.
I am printing the value and displayname. 
<snip>

another solution is grouping with key.

  <!-- grouping with the same displayposition -->
  <xsl:key name="displayposition" match="*[@displayposition]"
use="@displayposition"/>

  <xsl:template match="/">
    <table>
      <!-- get all possible keyvalues in sorted order -->
      <xsl:for-each select="o/com/hereyougo/*">
        <xsl:sort select="@displayposition"/>
        <tr>
          <th><xsl:value-of select="@displayname"/></th>
          <!-- now process all elements with the same key -->
          <xsl:for-each select="key('displayposition', @displayposition)" >
            <td><xsl:value-of select="." /></td>
          </xsl:for-each>
        </tr>
      </xsl:for-each>
    </table>
  </xsl:template>

Cheers,

Juergen


****************************************************************************
*
Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte 
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese 
eMail irrtuemlich erhalten haben, informieren Sie bitte sofort den 
Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren 
sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. 
If you are not the intended recipient (or have received this e-mail 
in error) please notify the sender immediately and destroy this e-mail. 
Any unauthorized copying, disclosure or distribution of the material 
in this e-mail is strictly forbidden.
****************************************************************************
*


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 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.