XSLT kliens oldalon

Apró programocska egy JavaScript XSLT-hez Firefoxra.

xsltProcessor = new XSLTProcessor();
 
function init(){
  xsltProcessor.reset();
  var myXMLHTTPRequest = new XMLHttpRequest();
  myXMLHTTPRequest.open("GET", "fields.xsl", false); //syncronous call with last param false
  myXMLHTTPRequest.send(null);
  var xslRef = myXMLHTTPRequest.responseXML;
  xsltProcessor.importStylesheet(xslRef);
}
 
function getRemoteXMLDocument(){
  var myXMLHTTPRequest = new XMLHttpRequest();
  myXMLHTTPRequest.open("GET", "example.xml", false); //syncronous call with last param false
  myXMLHTTPRequest.send(null);
  return myXMLHTTPRequest.responseXML;
}
 
function teszt(){
  var xmlRef = getRemoteXMLDocument();
  var fragment = xsltProcessor.transformToFragment(xmlRef, document);
  var frm = document.getElementById('proba');
  frm.appendChild(fragment);
}

a document változó a böngésző document globális változója