views:

553

answers:

2

I want to use firebug to debug and help be quickly finish some XSLT layout issues, but I cannot get the following code to perform and display the client side XSLT in Firebox (everything is fine in IE):

$().ready(function() {

   var oXMLHTTP
   var oXSLT

   if ($.browser.mozilla){
     oXMLHTTP = document.implementation.createDocument("","",null);
     oXSLT = document.implementation.createDocument("","",null);
   }else{            
     oXMLHTTP = new ActiveXObject("Microsoft.XMLDOM");
     oXSLT  = new ActiveXObject("Microsoft.XMLDOM");
   }
   oXMLHTTP.async = false; 
   oXSLT.async = false;
   oXSLT.load('Layout.xslt');

   var sURL = "somepage"

   /**/
   $.get(sURL,function(data){
      var sTranformedXML = "";
      if ($.browser.mozilla){
         oXMLHTTP.load(data);
         var xsltProcessor = new XSLTProcessor();
         xsltProcessor.importStylesheet(oXSLT);
         var mDoc = document.implementation.createDocument("","",null);
         sTranformedXML = xsltProcessor.transformToFragment(oXMLHTTP,mDoc);
      }else{
         oXMLHTTP.loadXML(data);
         sTranformedXML = oXMLHTTP.transformNode(oXSLT)
      }
      $("#main").html(sTranformedXML);
      $("#tbl_Not Grouped").insertAfter("tbl_Social Sciences");
   })// $.get           
})

Is there something that I have overlooked here?

I really only need the Firefox code testing. So, it does not need to be pretty.

+1  A: 

Gecko's XSL-T implementation is known to handle default namespaces wrongly. Try prefixing elements in your XML document and/or prefix elements in XPath queries in XSL document (do not forget to bind new prefixes)

Sergey Ilinsky
+1  A: 

This does not really answer your question per se, but you might consider taking a look at Google AJAXSLT, which wraps the various browsers' capabilities and "fills in the gaps:" link

David