<SCRIPT LANGUAGE="JavaScript">
function parseText2XML(text) {
var result;
if (window.DOMParser) {
parser = new DOMParser();
result = parser.parseFromString(text,"text/xml");
} else {
// IE
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
result = xmlDoc.loadXML(text);
}
return result;
}
function transform(xmlText, xslText) {
var result;
var xml = parseText2XML(xmlText);
var xsl = parseText2XML(xslText);
if (window.ActiveXObject) {
// IE
result = xml.transformNode(xsl);
} else if (document.implementation && document.implementation.createDocument) {
// code for Mozilla, Firefox, Opera, etc.
xsltProcessor=new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToFragment(xml,document);
var serializer = new XMLSerializer();
result = serializer.serializeToString(resultDocument);
}
return result;
}
</SCRIPT>