Index: openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/xml/XslTransform.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/xml/Attic/XslTransform.js,v diff -u -r1.1 -r1.2 --- openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/xml/XslTransform.js 7 Nov 2006 02:38:06 -0000 1.1 +++ openacs-4/packages/ajaxhelper/www/resources/dojo-ajax/src/xml/XslTransform.js 25 Dec 2006 16:39:59 -0000 1.2 @@ -10,16 +10,20 @@ dojo.provide("dojo.xml.XslTransform"); -dojo.xml.XslTransform = function(/*String*/ xsltUri) { +dojo.xml.XslTransform = function(/*String*/xsltUri){ // summary: - // dojo.xml.XslTransform is a convenience object that takes the URI String - // of an XSL file as a constructor argument. - // After each transformation all parameters will be cleared. + // dojo.xml.XslTransform is a convenience object that takes the URI + // String of an XSL file as a constructor argument. After each + // transformation all parameters will be cleared. Transformation is + // supported by IE, Mozilla, and partially by Opera. Other browsers + // (notably Safari) have not yet exposed their transformation + // primtives well enough to be useful. + // xsltUri: + // Url of the xslt document to transform nodes with. Transformation is + // acheived with the transformTo* methods on instances of this class. - // Note this is supported by IE and Mozilla ONLY. - dojo.debug("XslTransform is supported by Internet Explorer and Mozilla, with limited support in Opera 9 (no document function support)."); - var IS_IE = window.ActiveXObject ? true : false; + var IS_IE = dojo.render.html.ie; var ACTIVEX_DOMS = [ "Msxml2.DOMDocument.5.0", "Msxml2.DOMDocument.4.0", @@ -39,150 +43,207 @@ "MSXML2.XSLTemplate.3.0" ]; - function getActiveXImpl(activeXArray) { - for (var i=0; i < activeXArray.length; i++) { - try { + function getActiveXImpl(activeXArray){ + for(var i=0; i < activeXArray.length; i++){ + try{ var testObj = new ActiveXObject(activeXArray[i]); - if (testObj) { + if(testObj){ return activeXArray[i]; } - } catch (e) {} + }catch(e){} } dojo.raise("Could not find an ActiveX implementation in:\n\n " + activeXArray); } - if (xsltUri == null || xsltUri == undefined) { + if(xsltUri == null || xsltUri == undefined){ dojo.raise("You must pass the URI String for the XSL file to be used!"); return false; } - var xsltDocument = null; - var xsltProcessor = null; - if (IS_IE) { - xsltDocument = new ActiveXObject(getActiveXImpl(ACTIVEX_FT_DOMS)); - xsltDocument.async = false; - } else { - xsltProcessor = new XSLTProcessor(); - xsltDocument = document.implementation.createDocument("", "", null); - xsltDocument.addEventListener("load", onXslLoad, false); + var xsltDocument = null; + var xsltProcessor = null; + if(IS_IE){ + xsltDocument = new ActiveXObject(getActiveXImpl(ACTIVEX_FT_DOMS)); + xsltDocument.async = false; + }else{ + xsltProcessor = new XSLTProcessor(); + xsltDocument = document.implementation.createDocument("", "", null); + xsltDocument.addEventListener("load", onXslLoad, false); + } + xsltDocument.load(xsltUri); + + if(IS_IE){ + var xslt = new ActiveXObject(getActiveXImpl(ACTIVEX_TEMPLATES)); + xslt.stylesheet = xsltDocument; + xsltProcessor = xslt.createProcessor(); + } + + function onXslLoad(){ + xsltProcessor.importStylesheet(xsltDocument); + } + + function getResultDom(xmlDoc, params){ + if(IS_IE){ + addIeParams(params); + var result = getIeResultDom(xmlDoc); + removeIeParams(params); + return result; + }else{ + return getMozillaResultDom(xmlDoc, params); + } + } + + function addIeParams(params){ + if(!params){ return; } + for(var i=0; i