Click here to Skip to main content
13,900,411 members
Rate this:
Please Sign up or sign in to vote.
See more:
<<pre lang="xml"><pre lang="xml">?xml version="1.0" encoding="UTF-8"?>
  <ExperimentalSet GUID="Set01">
      <Name>The First Experimental Set</Name>
    <Experiments OrderBy="Value">
      <Experiment GUID="Expt0009" DesignIndex="15" RunIndex="12">11</Experiment>
      <Experiment GUID="Expt0014" DesignIndex="14" RunIndex="7" >25</Experiment>
      <Experiment GUID="Expt0013" DesignIndex="13" RunIndex="3" >37</Experiment>
      <Experiment GUID="Expt0012" DesignIndex="12" RunIndex="1" >41</Experiment>
      <Experiment GUID="Expt0011" DesignIndex="11" RunIndex="5" >54</Experiment>
      <Experiment GUID="Expt0010" DesignIndex="10" RunIndex="9" >69</Experiment>
  <ExperimentalSet GUID="Set02">
      <Name>The Second Experimental Set</Name>
    <Experiments OrderBy="Run Index">
      <Experiment GUID="Expt1012" DesignIndex="12" RunIndex="1" >1004</Experiment>
      <Experiment GUID="Expt1005" DesignIndex="5"  RunIndex="2" >1102</Experiment>
      <Experiment GUID="Expt1013" DesignIndex="13" RunIndex="3" >1324</Experiment>
      <Experiment GUID="Expt1007" DesignIndex="7"  RunIndex="4" >1921</Experiment>
      <Experiment GUID="Expt1011" DesignIndex="11" RunIndex="5" >1245</Experiment>

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=""

    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"

    <xsl:output method="html" indent="yes"/>
    <xsl:template match="ExperimentalSets">
          <script type="text/JavaScript">
            function parsingAttributes(control)
            var ctr= document.getElementById(control.text);
            function sortByNumber(divid,txt)

          <xsl:apply-templates select="ExperimentalSet">
  <xsl:template match ="ExperimentalSet">
    <xsl:variable name="NodeName">
      <xsl:value-of select="Identity/Name"/>
  <a href="#" onclick="parsingAttributes(this)">
    <xsl:value-of select="Identity/Name"/>
    <div id="{$NodeName}" style="display:none">
      <table border="4">
          <th onclick="sortByNumber('{$NodeName}',this)">Number</th>
          <th>Design Index</th>
          <th>Run Index</th>

        <xsl:for-each select ="Experiments/Experiment">
              <xsl:value-of select ="text()"/>
              <xsl:value-of select ="@GUID"/>
              <xsl:value-of select ="@DesignIndex"/>
              <xsl:value-of select ="@RunIndex"/>

  <br />


the related xsl file is the one shown above.
The need is to sort the html table contents based on the column clicks provided by the user.

This has to be done dynamically based on the user clicks.
i.e. if the user clicks on Number the contents are to be sorted based on number,if the user clicks on Design Index the data has to be sorted by design Index..

In short how do we sort the data dynamically based on events like the onclick in xslt.

Kindly post in your suggestions.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Please refer following link
Make all your tables sortable[^]

VarunKumarGB 18-Jan-11 3:58am
Thanks Sunasara

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.190306.1 | Last Updated 17 Jan 2011
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100