common XSLT solution in all browser
1 function transform(context, xslt) { 2 if (typeof XSLTProcessor != "undefined") { 3 var processor = new XSLTProcessor(); 4 processor.importStylesheet(xslt); 5 6 var result = processor.transformToDocument(context); 7 return (new XMLSerializer()).serializeToString(result); 8 9 } else if (typeof context.transformNode != "undefined") { 10 return context.transformNode(xslt); 11 } else { 12 throw new Error("No XSLT processor available."); 13 } 14 }