Go Back   CodingForums.com > :: Client side development > XML

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-01-2003, 09:48 PM   PM User | #1
kobruleht
New to the CF scene

 
Join Date: Jun 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
kobruleht is an unknown quantity at this point
Unhappy Unable to sort table (IE bug?)

I try to make a generic xml based table sort routing routine.
However, it seems that XSL stylesheet does not in IE 6

To reproduce:

1. create files test.htm, test.xsl and test.htc from data in the end of this message
2. run test.htm in IE 6
3. click in the item column

Observed result:

table is not sorted by item column

Expected result:

Table must be selected by item column


Note:

In test.xsl, if line

<xsl:sort select="$sortfield" order="{$sortorder}" />

is changed to

<xsl:sort select="item" order="{$sortorder}" />

The sorting is done.
So this is IE bug!

Any idea how to fix this so that sorting can be done by any column?
Or is it possible to use some other generic method for sorting by any column?



--------- test.htm contains:

<xml id="result" javaDSOCompatible="true">
<result>
<row><item>pine</item><price>4</price></row>
<row><item>orange</item><price>1</price></row>
<row><item>apple</item><price>3</price></row>
</result></xml>

Click in the item or price to sort
<TABLE DATASRC="#result"
style="BEHAVIOR: url(test.htc)" LANGUAGE="javascript">
<thead>
<th id="thdr" SortField="item">Item</th>
<th id="thdr" SortField="price">Price</th>
</thead>

<tr>
<td><span datafld=item></span></td>
<td><span datafld=price></span></td>
</tr>
</TABLE>
<xml id="xslSorted" src="test.xsl"></xml>

-------- test.xsl contains:


<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>
<xsl:param name="sortorder" select="'descending'"/>
<xsl:param name="sortfield" select="'xxx'"/>

<xsl:template match="/">
<result>
<xsl:for-each select="result/row" >
<xsl:sort select="$sortfield" order="{$sortorder}" />
<xsl:copy-of select="." />
</xsl:for-each>
</result>
</xsl:template>
</xsl:stylesheet>


------------ test.htc contains:

<script language=jscript>

element.attachEvent('onclick', onClick);

function onClick() {
srcElem = window.event.srcElement;
while (srcElem.tagName != "TR" && srcElem.tagName != "TABLE" && srcElem.tagName != "TH") {
srcElem = srcElem.parentElement;
}
if(srcElem.tagName == "TH") SortJS();
}


function SortJS()
{
var nLastCol = element.document.all.thdr.length;
var srcElem = window.event.srcElement;
var strSortOrder = "";
var strSortField = srcElem.SortField;

//Store away the current class name before it gets reset
strCurrClass = srcElem.className;


strSortOrder = "ascending";
SortPickList(strSortField, strSortOrder);
}

</script>

<script language="vbscript">

function SortPickList(strSortField, strSortOrder )

dim objXSL, objXML, objTemplate, objProcessor, strHTML, strDrinkType

Set objXML = CreateObject("Msxml2.FreeThreadedDOMDocument")
Set objXSL = CreateObject("Msxml2.FreeThreadedDOMDocument")

objXML.async = False
objXML.Loadxml result.xml

objXSL.async = False

' Chris recommendation:
objXSL.load "test.xsl"
'objXSL.Loadxml xslSorted.xml

Set objTemplate = CreateObject("MSXML2.XSLTemplate")
Set objTemplate.stylesheet = objXSL
Set objProcessor = objTemplate.createProcessor
objProcessor.input = objXML

objProcessor.AddParameter "sortfield", strSortField
objProcessor.AddParameter "sortorder", strSortOrder
objProcessor.Transform

'Store the results of the output into a string.
strXML = objProcessor.output

'Load up an XML DOM object from the recent XML output
objXML.loadxml strXML

objXML.selectNodes("//result")

'Load our Data Island using our new XML object
result.loadxml objXML.xml
end function
</script>

Last edited by Alex Vincent; 06-04-2003 at 06:05 PM..
kobruleht is offline   Reply With Quote
Old 06-18-2003, 09:17 AM   PM User | #2
Fly Swatter
New Coder

 
Join Date: Oct 2002
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Fly Swatter is an unknown quantity at this point
this may help you in ur mission

<xsl:sort select="*[name()=$sortfield]" order="{$sortorder}" />
Fly Swatter is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:08 PM.


Advertisement
Log in to turn off these ads.