Jump to content

Xsl Transform Using Javascript Without Activex


Guest Ananda Krishna N

Recommended Posts

Guest Ananda Krishna N

I read the chapter XSLT on the Client in XSLT Chapter. It uses ActriveX control for IE browser. when I run this higher version of IE, the browser ask user that whether you want to run ActiveX or not. This is I don't want. Is there any way to XSL Transform on the client without using ActiveX for IE.

Link to comment
Share on other sites

First of all for client-side XSLT you don't need scripting at all, you can achieve that simply by putting a processing instruction

<?xml-stylesheeet type="text/xsl" href="sheet.xsl"?>

into your XML document, before the root element. Then you can load the XML document into a browser window, and the browser, it it supports XSLT, will apply the transformation.If you want to script XSLT on the client then I think with IE 7 and 8 you can achieve that without using an ActiveXObject by loading the XML documents (i.e. the input XML and the stylesheet document) with XMLHttpRequest and then you can apply the transformNode method exposed on the responseXML:

var req1 = new XMLHttpRequest();req1.open('GET', 'input.xml', true);req1.onreadystatechange = function(){  if (req1.readyState === 4)  {	var req2 = new XMLHttpRequest();	req2.open('GET', 'sheet.xml', true);	req2.onreadystatechange = function()	{	  if (req2.readyState === 4)	  {		var doc = req1.responseXML;		var sheet = req2.responseXML;		if (typeof doc.transformNode != 'undefined')		{		  document.body.insertAdjacentHTML('beforeEnd', doc.transformNode(sheet));		}	  }	};	req2.send(null);  }};req1.send(null);

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...