Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / August 2006

Tip: Looking for answers? Try searching our database.

XSLT Transformation in Javascript

Thread view: 
Tom Cole - 29 Aug 2006 23:33 GMT
I am trying to create a cross-browser implementation that will take an
XML file, apply a XSL stylesheet to it and return a DOM stack of the
styled XML.

In non-IE browsers I am using something like the following
successfully:

NOTE: value is a global variable and element & url are passed to the
method. Element is the document element that is to contain the parsed
XML DOM and url points to the XSL stylesheet.

if (typeof XSLTProcessor != 'undefined') {
 var processor = new XSLTProcessor();
 var request = getXMLHttpRequest();
 if (request) {
   request.open("GET", url, false);
   request.send(null);
   var xsl = request.responseXML;
   processor.importStylesheet(xsl);
   var fragment = processor.transformToFragment(value, document);
   if (element)
     element.appendChild(fragment);
   }
   else {
     return;
   }
}

In IE there is no XSLTProcessor, but there is the XMLDOM ActiveX
component. Problem is I don't know how to get it to return me an XML
DOM, just text:

else {
 var processor = new ActiveXObject("Microsoft.XMLDOM");
 if (processor) {
   processor.async = false;
   processor.load(url);
   var xmlString = value.transformNode(processor);
   if (element) {
     element.innerHTML = xmlString;
 }
 else {
   return;
 }
}

I've only found the transformNode method which returns a String, but
nothing that will return actual DOM objects.

Thanks in advance.
David Harper - 30 Aug 2006 07:16 GMT
> I am trying to create a cross-browser implementation that will take an
> XML file, apply a XSL stylesheet to it and return a DOM stack of the
> styled XML.
[SNIP]

This is not the appropriate newsgroup for a query about JavaScript.
This newsgroup is for discussions about database programming with Java.

I suggest that you send your query to comp.lang.javascript if you hope
to receive help with your problem.

David Harper
Cambridge, England
Tom Cole - 30 Aug 2006 14:00 GMT
Thank you. I had tried to delete the post (but apparently wasn't fast
enough).

> > I am trying to create a cross-browser implementation that will take an
> > XML file, apply a XSL stylesheet to it and return a DOM stack of the
[quoted text clipped - 9 lines]
> David Harper
> Cambridge, England


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.