topical media & game development
professional-javascript-15-MozillaXsltExample4.htm / htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Mozilla XSLT Example</title>
<script type="text/javascript" src="detect.js"></script>
<script type="text/javascript" src="xmldom.js"></script>
<script type="text/javascript">
Node.prototype.transformNode = function (oXslDom) {
var oProcessor = new XSLTProcessor();
oProcessor.importStylesheet(oXslDom);
var oResultDom = oProcessor.transformToDocument(this);
var sResult = oResultDom.xml;
if (sResult.indexOf("<transformiix:result") > -1) {
sResult = sResult.substring(sResult.indexOf(">") + 1, sResult.lastIndexOf("<"));
}
return sResult;
};
window.onload = function () {
var oXmlDom = new XmlDom();
var oXslDom = new XmlDom();
oXmlDom.async = false;
oXslDom.async = false;
oXmlDom.load("employees.xml");
oXslDom.load("employees4.xslt");
alert(oXmlDom.transformNode(oXslDom));
}
</script>
</head>
<body>
<p>This example loads employees.xml and transforms it using employees4.xslt.
The XSLT should print out only text without XML code, which is displayed
in an alert.</p>
<div id="divResult"></div>
</body>
</html>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.