var oXML, oXSLT;
function InitPage() {
if ( typeof(oXParams) != "object" || oXParams == null ) {
alert("Object oXParams is not initialized");
}
oXML = new CXML(oXParams.base_dir + '/phones.xml');
oXSLT = new CXSLT(oXParams.base_dir + '/phones.xsl');
renderPage(Transform('', '', ''));
}
function find(f) {
renderPage(Transform(f.loc.value, f.phone.value, f.addr.value));
}
// ------- Classs CXSLT keeps XSLT stylesheet ----------
//
//
function CXSLT(xsltURL) {
this._xsltDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
this._xsltDoc.async = false;
this._xsltDoc.load(xsltURL);
var err = this._xsltDoc.parseError;
if ( err.errorCode != 0 ) {
alert("You have error [code=" + err.errorCode + "] " + err.reason);
}
}
//
//
CXSLT.prototype.getXSLTDoc = function() {
return this._xsltDoc;
}
// ------- Classs CXML keeps XML document ----------
//
//
function CXML(xmlURL) {
this._xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
this._xmlDoc.async = false;
this._xmlDoc.load(xmlURL)
var err = this._xmlDoc.parseError;
if ( err.errorCode != 0 ) {
alert("You have error [code=" + err.errorCode + "] " + err.reason);
}
}
//
//
CXML.prototype.getXMLDoc = function() {
return this._xmlDoc;
}
function Transform(loc, phone, addr) {
var xslProc;
var xslt = new ActiveXObject("Msxml2.XSLTemplate");
xslt.stylesheet = oXSLT.getXSLTDoc();
xslProc = xslt.createProcessor();
xslProc.input = oXML.getXMLDoc();
xslProc.addParameter("base.dir", oXParams.base_dir);
xslProc.addParameter("loc", loc);
xslProc.addParameter("phone", phone);
xslProc.addParameter("addr", addr);
xslProc.transform();
return xslProc.output;
}
function renderPage(contents) {
oPhones.innerHTML = contents;
}