function XSLTProc(sxml, sxsl, holderId){
    this.holder=document.getElementById(holderId);
    if (window.ActiveXObject) {
        var xslt = new ActiveXObject("Msxml2.XSLTemplate");
        var xsl = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
        xsl.async = false;
        xsl.resolveExternals = false;
        xsl.load(sxsl);
        xslt.stylesheet = xsl;
        this.xml = new ActiveXObject("Msxml2.DOMDocument");
        this.xml.async = false;
        this.xml.resolveExternals = false;
        if(sxml != '')
            this.xml.load(sxml);
        this.proc = xslt.createProcessor();
        this.setParam=function(name, value){this.proc.addParameter(name, value);};
        this.go=function(){
            this.proc.input = this.xml;
            this.proc.transform();
            this.holder.innerHTML=this.proc.output;
        }

        this.setXML=function(newXML){
            this.xml.load(newXML);
        }


    } else {
       this.proc = new XSLTProcessor();
       var myXMLHTTPRequest = new XMLHttpRequest();
       myXMLHTTPRequest.open("GET", sxsl, false);
       myXMLHTTPRequest.send(null);
       var xslStylesheet = myXMLHTTPRequest.responseXML;
       this.proc.importStylesheet(xslStylesheet);
       if(sxml != ''){
           myXMLHTTPRequest = new XMLHttpRequest();
           myXMLHTTPRequest.open("GET", sxml, false);
           myXMLHTTPRequest.send(null);
           this.xml = myXMLHTTPRequest.responseXML;
       }

       this.setParam=function(name, value){this.proc.setParameter(null, name, value);};

       this.go=function(){
           var fragment = this.proc.transformToFragment(this.xml, document);
           this.holder.innerHTML = "";
           this.holder.appendChild(fragment);
       }
       
       this.setXML=function(newXML){
           myXMLHTTPRequest = new XMLHttpRequest();
           myXMLHTTPRequest.open("GET", newXML, false);
           myXMLHTTPRequest.send(null);
           this.xml = myXMLHTTPRequest.responseXML;
       }
       
       return false;
    }
}

function soap(sxml){
    if (window.ActiveXObject) {
        xml = new ActiveXObject("Msxml2.DOMDocument");
        xml.async = false;
        xml.resolveExternals = false;
        xml.load(sxml);
    } else {
       myXMLHTTPRequest = new XMLHttpRequest();
       myXMLHTTPRequest.open("GET", sxml, false);
       myXMLHTTPRequest.send(null);
       xml = myXMLHTTPRequest.responseXML;
    }
    dom=xml.documentElement;
    return dom;
}


function soapp(server, sxml){ //using a post method to post large data
    if (window.ActiveXObject) {
		var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		xmlhttp.Open("POST", server, false);
		xmlhttp.Send(sxml);
        xml=xmlhttp.responseXML;
    } else {
       myXMLHTTPRequest = new XMLHttpRequest();
       myXMLHTTPRequest.open("POST", server, false);
       myXMLHTTPRequest.send(sxml);
       xml = myXMLHTTPRequest.responseXML;
    }
    dom=xml.documentElement;
    return dom;
}


if( document.implementation.hasFeature("XPath", "3.0") )
{
	XMLDocument.prototype.selectNodes = function(cXPathString, xNode)
	{
		if( !xNode ) { xNode = this; }

		var oNSResolver = this.createNSResolver(this.documentElement)
		var aItems = this.evaluate(cXPathString, xNode, oNSResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
		var aResult = [];
		for( var i = 0; i < aItems.snapshotLength; i++)
		{
			aResult[i] =  aItems.snapshotItem(i);
		}

		return aResult;
	}
	XMLDocument.prototype.selectSingleNode = function(cXPathString, xNode)
	{
		if( !xNode ) { xNode = this; }

		var xItems = this.selectNodes(cXPathString, xNode);
		if( xItems.length > 0 )
		{
			return xItems[0];
		}
		else
		{
			return null;
		}
	}

	Element.prototype.selectNodes = function(cXPathString)
	{
		if(this.ownerDocument.selectNodes)
		{
			return this.ownerDocument.selectNodes(cXPathString, this);
		}
		else{throw "For XML Elements Only";}
	}

	Element.prototype.selectSingleNode = function(cXPathString)
	{
		if(this.ownerDocument.selectSingleNode)
		{
			return this.ownerDocument.selectSingleNode(cXPathString, this);
		}
		else{throw "For XML Elements Only";}
	}

}


