xsl-list
[Top] [All Lists]

AW: Vertical table display with sort

2003-04-30 02:09:40
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="*[(_at_)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



<Prev in Thread] Current Thread [Next in Thread>