You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by jb...@apache.org on 2010/08/16 18:01:08 UTC

svn commit: r986001 - /commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/ie.js

Author: jbeard
Date: Mon Aug 16 16:01:08 2010
New Revision: 986001

URL: http://svn.apache.org/viewvc?rev=986001&view=rev
Log:
Fixed bug where parameters were not being used in in-browser XSL transformation in IE. Neededto use new, different ActiveX-based APIs. This may not be the most performant, portable, or robust code. It passes manual unit testing, but seems to be broken when using automated, in-browser unit tests with selenium in IE8.

Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/ie.js

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/ie.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/ie.js?rev=986001&r1=986000&r2=986001&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/ie.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/ie.js Mon Aug 16 16:01:08 2010
@@ -9,18 +9,47 @@ function(xmlUtil){
 					[transformList]			:
 					transformList;
 
+
+		//prepare processors
+		//FIXME: this works in IE on WinXP 3, but due to all of the ActiveX code here, i'm not sure how portable, reliable, or performant it is
+		//the previous solution was to use the docToTransform.transformNode method, which worked well, but I was unable to find a way to
+		//use this method, and also pass in transform parameters. hence the ActiveX. 
+		var processors = [];
+		for(var i=0, l = transformList.length; i<l; i++){
+			 var xsldoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.3.0");
+			 var xslt = new ActiveXObject("Msxml2.XSLTemplate.3.0"); 
+			 xsldoc.async=false;
+			 xsldoc.loadXML(transformList[i].xml);
+
+			 xslt.stylesheet = xsldoc;
+			 var xslproc = xslt.createProcessor();
+
+			 for(paramName in params){
+				 var paramValue = params[paramName];
+				 if ((typeof paramValue == "string") || (typeof paramValue == "boolean")) 
+					 xslproc.addParameter(paramName,paramValue);
+			 }
+
+			 processors.push(xslproc);
+		}
+
 		//transform to IR
 		var docToTransform = sourceDocument;
-		for(var i=0; i < transformList.length-1; i++){
-			var t = transformList[i];
+		for(var i=0,l=processors.length; i < l-1; i++){
+			var p = processors[i];
+
+			p.input = docToTransform;
+			p.transform();
 
-			var txt = docToTransform.transformNode(t); 
+			var txt = p.output
 			docToTransform = xmlUtil.parseFromString(txt);
 		}
 
-		var lastFilter = transformList[transformList.length-1];
+		var lastFilter = processors[processors.length-1];
 
-		var txt = docToTransform.transformNode(lastFilter ); 
+		lastFilter.input = docToTransform;
+		lastFilter.transform();
+		var txt = lastFilter.output
 
 		var toReturn;
 		switch(output){