topical media & game development
basic-ajax-08-StaticXSLT.js / js
function loadDocument(fileName)
{
var xmlDoc = window.ActiveXObject ? new ActiveXObject("MSXML2.DOMDocument.3.0") :
document.implementation.createDocument("","",null);
xmlDoc.async = false;
xmlDoc.load(fileName);
return xmlDoc;
}
function getTransformedHTML(xmlDoc, xslDoc) {
var html = "";
if (window.XSLTProcessor)
{
var xsltProc = new XSLTProcessor();
xsltProc.importStylesheet(xslDoc);
var fragment = xsltProc.transformToFragment(xmlDoc, document);
html = new XMLSerializer().serializeToString(fragment);
}
else if (window.ActiveXObject)
{
html = xmlDoc.transformNode(xslDoc);
}
return html;
}
function GenerateCart()
{
var xmlDoc = loadDocument("cart.xml");
var xslDoc = loadDocument("cart.xsl");
document.getElementById("cart").innerHTML = getTransformedHTML(xmlDoc, xslDoc);
}
function AddRemoveItem() {}
(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.