473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Clientside filtering and sorting xml with javascript: Work in IEbut not Firefox


I would like to use an XSL/HTML template to sort XML data dynamically on
the client side.

As it is, I found a tutorial showing how to do this on the following
site ...

http://www.bayes.co.uk/xml/portal.as...ing/filter.xml

I experimented with the examples and found that they would run fine on a
local PC (without installing a web-server). That is just what I need!

However, when I tried to run the same thing with FireFox (under Linux),
I got the following message ...

You will need to have the latest version of MSXML installed in "replace"
*NOT* "side-by-side" mode to view the tutorial. Or IE6+.

This message (and references to 'ActiveX' and 'MSXML' in the javascript
below) shows me that the code I had found is very MicroSoft specific.
Arrgghh!

This combination of JavaScript and XML/XSL/HTML (with client-side
processing) would be perfect for my needs so what I really like to know
is whether there are ways of handling the XML/XSL without dependence on
a Microsoft platform?

I have enclosed an excerpt of the script (below) and hope that someone
out there can help me get this working without needing Bill Gates help.

Regards and thanks,
Alan Searle

Script excerpt:

<script language="javascript" type="text/javascript">

function sort(column){
try{
var s = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
var x = document.XMLDocument;
if (x == null){
x = navigator.XMLDocument;
s.loadXML(navigator.XSLDocument.xml);
}else{
s.loadXML(document.XSLDocument.xml);
}
var tem = new ActiveXObject("MSXML2.XSLTemplate");
tem.stylesheet = s;
var proc = tem.createProcessor();
proc.addParameter("column", column);
proc.input = x;
proc.transform();
var str = proc.output;

var newDoc = document.open("text/html");
newDoc.write(str);
navigator.XMLDocument = x;
navigator.XSLDocument = s;
newDoc.close();
}catch(exception){
}
}
</script>
Nov 23 '05 #1
2 6153


Alan Searle wrote:

This combination of JavaScript and XML/XSL/HTML (with client-side
processing) would be perfect for my needs so what I really like to know
is whether there are ways of handling the XML/XSL without dependence on
a Microsoft platform?
Mozilla has client-side XSLT support since 1.0 and a frozen API to
script XSLT since 1.2 I think, see here for details:
<http://www.mozilla.org/projects/xslt/>
<http://www.mozilla.org/projects/xslt/js-interface.html>
Safari has client-side XSLT support by now I think based on libxml but I
am not aware on any API exposed to script.
The Opera 9 preview released some weeks ago has client-side XSLT support
based on Opera's own implementation of XSLT but tries to expose the same
API Mozilla exposes:
<http://snapshot.opera.com/windows/w90p1.html>
<http://snapshot.opera.com/unix/u90p1.html>
s.loadXML(document.XSLDocument.xml);


Mozilla does not expose XSLDocument if you let the browser do a
transformation thus if you want to use XSLT and script in Mozilla it is
usually better and easier to start with a HTML document with script that
loads XML and stylesheet as needed and performs the transformation.

The whole IE approach with transforming to a string and inserting that
into an HTML document (or even replacing the complete HTML document) is
caused by the separate DOM implementations of HTML DOM by MSHTML and XML
DOM by MSXML. In Mozilla you can easily transform to a result fragment
with DOM nodes which can directly by inserted into the existing document.

However if you want to use client-side XSLT and script then in both IE
and Mozilla you face the issue to decide how to combine the rather
different APIs and their preferred (DOM result in Mozilla, string result
in IE) but incompatible use.

Currently if the aim is client-side sorting and filtering for a web
application then XSLT might not be the best option to reach a cross
browser compatible solution, you could rather set up appropriate
JavaScript data structures/objects and manipulate the HTML DOM only.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 23 '05 #2
Hi Martin,

Thanks for your tips and clarification.
Currently if the aim is client-side sorting and filtering for a web
application then XSLT might not be the best option to reach a cross
browser compatible solution, you could rather set up appropriate
JavaScript data structures/objects and manipulate the HTML DOM only.


This sounds interesting and I will be googling on these keywords.

Indeed, if you know of any tutorials or good sources of information (on
client side processing of structured data) then I'd be interested to hear.

Regards,
Alan Searle.
Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Bullock | last post by:
Hello, I am at wit's end with an array sorting problem. I have a simple table-sorting function which must, at times, sort on columns that include entries with nothing but a space (@nbsp;). I...
22
by: mike | last post by:
If I had a date in the format "01-Jan-05" it does not sort properly with my sort routine: function compareDate(a,b) { var date_a = new Date(a); var date_b = new Date(b); if (date_a < date_b)...
5
by: Richard | last post by:
Hi, I have a form that take some time to load due to many comboboxes and at least 8 subforms. When I filter or sort the main form I get an error message and then Access shuts down. They ask if...
0
by: Christian Hofmann | last post by:
Hello, I am using .Net Framework 2.0 Beta and for testing firefox. I disabled JavaScript in Firefox and now the gridview sorting and paging does not work. Evenery link is calling, for example,...
0
by: ber.janssens | last post by:
Hi, I am trying the new ObjectDataSource from ASP.NET 2.0. I connected a Gridview with ObjectDataSource which is connected to a webservice which returns a DataSet. In the Webmethod I return...
3
by: Harry Haller | last post by:
Hello, I want to implement a generic list which will be used to display 7 columns in a GridView. One should be able to sort, filter and page each of the 7 columns. Ideally the filter should be...
7
by: Kamal | last post by:
Hello all, I have a very simple html table with collapsible rows and sorting capabilities. The collapsible row is hidden with css rule (display:none). When one clicks in the left of the...
2
by: cluce | last post by:
i have a table sorting feature on my website that works everywhere else except in firefox. but the example code does work in firefox. this has me stumped. The problem is the links in the table...
0
by: Yarik | last post by:
Hello, Here is a sample (and very simple) code that binds an Access 2003 form to a fabricated ADO recordset: ' Create recordset... Dim rs As ADODB.Recordset: Set rs = New ADODB.Recordset '...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.