Subject: [xsl] xsl:sort Please Help From: Paul_B_Grimes@xxxxxxxxxx Date: Thu, 28 Jun 2001 13:25:01 -0700 |
I am having problems using xsl:sort. I have found that the 'order-by' element works fine, but I need to sort numerically also. I use the 'order-by' element with basically the same xsl (t) sheet. I just can't understand why xsl:sort isn't working. I have included my xsl code and a link to a site where I am testing this application. http://www22.brinkster.com/pgrimes/XML%20Project%20Sorter/project.html <current_projects> <xsl:for-each xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:sort select="cost" data-type="number"/> <project> <project_title> <xsl:value-of select="project_title"/> </project_title> <project_number> <xsl:value-of select="project_number"/> </project_number> <start_date> <xsl:value-of select="start_date"/> </start_date> <completion_date> <xsl:value-of select="completion_date"/> </completion_date> <cost> <xsl:value-of select="cost"/> </cost> <contact_name> <xsl:value-of select="contact_name"/> </contact_name> <contact_number> <xsl:value-of select="contact_number"/> </contact_number> </project> </xsl:for-each> </current_projects> One Idea I have as to why it doesn't work is that maybe the sort element doesn't interface with javascript well. I assign the appropriate xslt file to my xml file using java script in an html page. Here is the code: <html> <body> <link rel="stylesheet" type="text/css" href="ProjectSorted.css" /> <XML id="xmldso"></XML> <XML id="sortTitle" src="sortTitle.xslt"></XML> <XML id="sortProjectNum" src="sortProjectNum.xslt"></XML> <XML id="sortStartDate" src="sortStartDate.xslt"></XML> <XML id="sortCompleteDate" src="sortCompleteDate.xslt"></XML> <XML id="sortCost" src="sortCost.xslt"></XML> <XML id="sortName" src="sortName.xslt"></XML> <XML id="sortContactNum" src="sortContactNum.xslt"></XML> <SCRIPT language="javascript"> xmldso.async = false; xmldso.load("project.xml"); var xmldoc = xmldso.cloneNode(true); function ApplyStyleSheet(xsldoc){ xmldoc.documentElement.transformNodeToObject(xsldoc.documentElement,xmldso.XMLDocument); } function doMouseOver() { event.srcElement.parentElement.style.background = "lightsteelblue"; } function doMouseOut() { event.srcElement.parentElement.style.background = "whitesmoke"; } </SCRIPT> <br /> <br /> <a href="Create%20XML/createxml.asp">Click here to submit a project to be added to this page.</a><br /> <div align="center"><h1>Click on a heading to sort by the corresponding information.</h1></div> <table id="table" datasrc='#xmldso' Border="1" bordercolor="steelblue" bgcolor="steelblue" cellpadding="3" width="100%" align="center"> <thead> <th> <a href="javascript:ApplyStyleSheet(sortTitle.XMLDocument);">Project Title</a> </th> <th> <a href="javascript:ApplyStyleSheet(sortProjectNum.XMLDocument);"> Project Number</a> </th> <th> <a href="javascript:ApplyStyleSheet(sortStartDate.XMLDocument);"> Start Date</a> </th> <th> <a href="javascript:ApplyStyleSheet(sortCompleteDate.XMLDocument);"> Completion Date</a> </th> <th> <a href="javascript:ApplyStyleSheet(sortCost.XMLDocument);">Cost</a> </th> <th> <a href="javascript:ApplyStyleSheet(sortName.XMLDocument);">Contact Name</a> </th> <th> <a href="javascript:ApplyStyleSheet(sortContactNum.XMLDocument);"> Contact Number</a> </th> </thead> <tr onMouseOver="doMouseOver()" onMouseOut="doMouseOut()"> <td width="137"><font size="3"><span datafld="project_title"></span></ font></td> <td width="137"><font><span datafld="project_number"></span><br /></ font></td> <td width="137"><font><span datafld="start_date"></span><br /></font></ td> <td width="137"><font><span datafld="completion_date"></span><br /></ font></td> <td width="96"><font><span datafld="cost"></span><br /></font></td> <td width="178"><font><span datafld="contact_name"></span><br /></font ></td> <td width="137"><font><span datafld="contact_number"></span><br /></ font></td> </tr> </table> </body> </html> Thanks a lot for any input... Paul Grimes XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] conditionally accessing a, Clapham, Paul | Thread | RE: [xsl] xsl:sort Please Help, Michael Kay |
RE: [xsl] Generating Link Reference, Sebastian Rahtz | Date | [xsl] using preceding in fo:static-, Lisa Rupe |
Month |