This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Sortable data-table



Hi,
I have a xml-file that respresents a data table, and a xsl-file that
shows this table. What I want to do is this: When a column header is
pressed(it`s a button) sort the resulting html-page on that column.
For example, my xml-file looks like:

<?xml version="1.0" encoding="ISO8859-1"?>
<!DOCTYPE dataset PUBLIC 'datasetDTD'  
http://localhost/xmlDocs/dataset.dtd'>
<?xml-stylesheet type="text/xsl" 
href="http://localhost/xmlDocs/dataset.xsl"?>
<?cocoon-process type="xslt"?>

<dataset>
  <metaData>
    <tableName>EMPLOYEES</tableName>
    <columnInfo name="EMP_NO" type="SmallInt" size="6"/>
    <columnInfo name="FIRST_NAME" type="VarChar" size="15"/>
    <columnInfo name="LAST_NAME" type="VarChar" size="20"/>
  </metaData>
  <data>
    <row>
      <column name="EMP_NO">2</column>
      <column name="FIRST_NAME">Robert</column>
      <column name="LAST_NAME">Nelson</column>
    </row>
    <row>
      <column name="FIRST_NAME">K. J.</column>
      <column name="LAST_NAME">Weston</column>
      <column name="EMP_NO">11</column>
    </row>
    <row>
      <column name="FIRST_NAME">Luke</column>
      <column name="EMP_NO">61</column>
      <column name="LAST_NAME">Leung</column>
    </row>
  </data>
</dataset>

And my xsl-file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" indent="yes"/>
<xsl:template match="/">
<xsl:processing-instruction 
name="cocoon-format">type="text/html"</xsl:processing-instruction>
  <html>
    <body>
      <table border="1" width="60%" bgcolor="WHITE" cellspacing="2" 
cellpadding="2" frame="border">
        <caption>
	    <xsl:value-of select="dataset/metaData/tableName"/>
	  </caption>
	  <tr>
	    <xsl:for-each select="dataset/metaData/columnInfo">
	      <th>
		  <INPUT>
		  <xsl:attribute name="TYPE">SUBMIT</xsl:attribute>
		  <xsl:attribute name="VALUE">
		    <xsl:value-of select="@name"/>
		  </xsl:attribute>
		  </INPUT>
		</th>
	    </xsl:for-each>
	  </tr>
  	  <xsl:for-each select="dataset/data/row">
	    <xsl:variable name="row" select="."/>
          <tr>
	      <xsl:for-each select="/dataset/metaData/columnInfo">
		  <td>
		    <xsl:value-of select="$row/column[@name = current()/@name]"/>
		  </td>
		</xsl:for-each>
	    </tr>
	  </xsl:for-each>
	</table>
    </body>
  </html>
</xsl:template>
</xsl:stylesheet>

It there a way to do this? And if so, how?
Any suggestions and/or examples are greatly appreciated.

J.S. Koldenhof
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]