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     }

 

posted on 2013-05-18 17:14  雷音  阅读(143)  评论(0编辑  收藏  举报

导航