473,386 Members | 1,827 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,386 software developers and data experts.

How best to apply XSL to responseXML from XMLHttpRequest??

Hi all,

I'm making Ajax-type calls that return XML, and rather than parsing the
XML with DOM and building the nodes by hand, it seems much better and
well-designed to get the XML response, get an XSLT stylesheet, apply it
to the XML, and insert the resulting node (containing an HTML table)
into the document at a div.

But I keep getting javascript errors about not being able to insert the
document at this point in the hierarchy, and also XML parsing errors.
This is tough to debug, so I'm looking for advice. Any takers?

TIA,
Jonathon

Jan 6 '06 #1
1 1761

j_*********@bigfoot.com wrote:
I'm making Ajax-type calls that return XML, and rather than parsing the
XML with DOM and building the nodes by hand, it seems much better and
well-designed to get the XML response, get an XSLT stylesheet, apply it
to the XML, and insert the resulting node (containing an HTML table)
into the document at a div.
Mozilla does support that approach if you use transformToFragment, see
<http://www.mozilla.org/projects/xslt/js-interface.html>
Here is an example:
<http://home.arcor.de/martin.honnen/operaBugs/op9/XSLT/transformToFragment1.html>
Opera 9 preview also implements the API Mozilla has but what I have
tested so far while they have the methods like transformToFragment
implemented the results might differ from what Mozilla does. But as that
is only a preview of Opera 9 I am rather sure they improve that before
version 9 will be released.
IE with MSXML (3 and later) does not implement anything to produce nodes
with XSLT that could be inserted into a HTML document. Rather with MSXML
you need to use transformNode to get a string result and then use
properties (e.g. innerHTML, outerHTML) or methods (e.g.
insertAdjacentHTML) IE exposes to parse HTML snippets into nodes
inserted into the HTML document.
But I keep getting javascript errors about not being able to insert the
document at this point in the hierarchy, and also XML parsing errors.


You will need to provide more details on your code and on which browser
gives exactly which error. Post a URL if you have but do some work
yourself to isolate the problems to simple cases you can't solve.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 6 '06 #2

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

Similar topics

9
by: Chris Smith | last post by:
Been banging my head against this one for some time. I'm attempting to use XmlHTTPRequest to read an XML document from the web server and interact with it using the DOM. So far, I've had less...
2
by: Lan Vuong | last post by:
I am using the XMLHttpRequest object to get an XML response from a servlet. I check the readyState (4) on my asynchronous call and also check the parseError.errorCode (0). Everything seems to work...
2
by: Marco Laponder | last post by:
Hi All, I am using XmlHttpRequest object within Firefox to get a xml document from the servlet. The reponseText is set but the responseXml is null. My Code is: req = new XMLHttpRequest();...
3
by: joker | last post by:
Thanks in Advance. I'm trying to find out why my responseXML is empty when the Content-Type for my request is "text/xml". I'm calling into a servlet from a web page on the same domain returning...
0
by: lprisr | last post by:
Hi, With XmlHttpRequest object, using .responseText ALWAYS force the data into utf-8. I am trying to preserve encoding, so I am looking to use .responseXML. Also I am using Atlas, so I can't...
7
by: KaNos | last post by:
Hello aspx world, I consume a webservice with Javascript functions. But the response is ok and, very strange, document is null. How to resolve this problem thanks ?????? ...
14
by: webEater | last post by:
I downloaded IE7 and tried out the native XMLHttpRequest support. I think there is an object in IE7 called "XMLHttpRequest" but I ask me why it is called "XML"HttpRequest. I made a request to an...
8
dmjpro
by: dmjpro | last post by:
i m generating a xml file through jsp file using AJAX. my response header in jsp file is like this .. <%@ page contentType = "text/xml;charset = WINDOWS-1252"%> when i do...
8
by: =?ISO-8859-1?Q?Une_B=E9v?==?ISO-8859-1?Q?ue?= | last post by:
I have a page here : <http://thoraval.yvon.free.fr/Fixed_layout/import_nodes.xhtml> where i import nodes using XMLHttpRequest. it's ok when importing an SVG file (click on "Actions" + "Import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.