How to apply xml to xslt in javascript?

Here is the function:

 

function transFormXml(xmlData, xsltData) {
try {
try {
return xmlData.transformNode(xsltData);
}
catch (e) {
var xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsltData);
return getXmlString(xsltProcessor.transformToFragment(xmlData, document));
}
} catch (e)
{ alert(e); }

return null;
}