views:

482

answers:

1

Firefox 3 and XML/XSLT

I am relatively new to developing web apps with client-side processing in Firefox. I have a few straight-forward questions regarding the use of XML/XSLT in Firefox. I send an initial XML document with an XSLT reference to the browser. The browser successfully transforms the XML to XHTML using the referenced XSLT stylesheet.

This works well in both Internet Explorer 6+ and Firefox 3+. Now I must make changes to the XML document and XSLT stylesheet in JavaScript then retransform the XML to HTML. I am not looking at creating an XML document or getting one from an AJAX HTTPRequest. I am only concerned with the original XML document sent to the browser.

With IE, this is clear. In Firefox I am having difficulties probably due to lack of documentation. To perform a new transformation in JavaScript you need two objects and one operation:

Object/Operation --> In Internet Explorer 6+ JavaScript

The initial XML document sent to the browser-->document.XMLdocument

The initial XSLT document referenced in the XML via xml-stylesheet --> document.XSLdocument

Transforming XML with XSLT to get new HTML output -->
document.XMLdocument.documentElement.transformNode(document.XSLdocument)

What I am looking for is the equivalent to these 3 notions in the Firefox 3 DOM. I have done a pretty exhaustive search on the web and came up with ways to do XML manipulation but not with the initial XML and XSL documents.

Can anyone point me in the right direction? Thank you.

A: 

Emle - Electronic Mathematics Laboratory Equipment Javascript file emle_lab.js uses parseFromString() to create a document from a string:

  var inputText = '<?xml version="1.0" encoding="UTF-8"?>' +
    '<emle xmlns="http://emle.sf.net/emle02"&gt;' +
    '  <lab refid="' + aLabId + '"></lab>' +
    '</emle>';
  var inputDoc = new DOMParser().parseFromString(inputText, "application/xml"); 
  var xsltDoc = emleHttpGetXML('emle_lab.xsl'); 
  var processor = new XSLTProcessor();
  processor.setParameter(null, 'emleLang',  aLang);
  processor.importStylesheet(xsltDoc);
  var outputDoc = processor.transformToDocument(inputDoc.firstChild);
C.W.Holeman II