The following HTML file can be used to try the XSLT transformation and see the results.
<html>
<head>
<title></title>
</head>
<body onload="init()">
<div><input type="text" id="xmlName" value="text.xml"></div>
<div><input type="text" id="xslName" value="text.xsl"></div>
<div><input type=button value="transform" onclick="trans();"></div>
<div id="divErr"></div>
<pre id="preRes" style="background:blue;color:gold"></pre>
</body>
<script language="javascript">
function trans()
{
xmlFile=xmlName.value;
xslFile=xslName.value;
if (xmlFile == "" || xslFile == "")
{
divErr.innerHTML = "invalid xml/xsl file names.";
}
var xsl = new ActiveXObject("MSXML2.DOMDOCUMENT.6.0");
var xml = new ActiveXObject("MSXML2.DOMDocument.6.0");
xml.validateOnParse = false;
xml.async = false;
xml.load(xmlFile);
if (xml.parseError.errorCode != 0)
divErr.innerHTML = "XML Parse Error : " + xml.parseError.reason;
xsl.async = false;
xsl.resolveExternals = true;
xsl.load(xslFile);
if (xsl.parseError.errorCode != 0)
divErr.innerHTML = "XSL Parse Error : " + xsl.parseError.reason;
try
{
res = xml.transformNode(xsl.documentElement);
preRes.innerText = res;
}
catch(err)
{
divErr.innerHTML = "Transformation Error:"
+err.number+"*"+err.description;
}
}
</script>
</html>