function CreateHTML( oXML, oXSL )
{
  result = "";

  if (oXML.parseError.errorCode != 0)
  {
    // alert("error");
    result = reportParseError(oXML.parseError);
  }
  else
  {
    if (oXSL.XMLDocument.parseError.errorCode != 0)
    {
      alert("error");
      result = reportParseError(oXSL.XMLDocument.parseError);
    }
    else
    {
      //alert("Transforming...");
      try {
        result = oXML.transformNode(oXSL.XMLDocument);
      }
      catch (exception) {
        result = reportRuntimeError(exception);
      }
    }
  }
  return result;
}

function CreateHTMLEx( oXML, oXSL )
{
  result = "";


  alert("In CreateHTMLEx" + oXML + " " + oXML.parseError );
  if (oXML.parseError.errorCode != 0)
  {
    //  alert("error");
    result = reportParseError(oXML.parseError);
  }
  else
  {
    //if (oXSL.XMLDocument.parseError.errorCode != 0)
    if (oXSL.parseError.errorCode != 0)
    {
      //alert("error");
      result = reportParseError(oXSL.parseError);
    }
    else
    {
      try {
        result = oXML.transformNode(oXSL);
      }
      catch (exception) 
      {
        alert("Runtime Error");
        result = reportRuntimeError(exception);
      }
    }
  }
  return result;
}

function CreateHTMLfromURLS( sXMLUrl, sXSLUrl )
{
  var oXML;
  var oXSL;

  oXML = loadXMLDoc(sXMLUrl);
  alert("in here");
  oXSL = loadXMLDoc(sXSLUrl);

  var os = new XMLSerializer().serializeToString(oXSL);
  alert(os);
  //alert("sXSLUrl = " + sXSLUrl + " : " + oXSL.text );
  
  //return CreateHTML(oXML,oXSL);
  return CreateHTMLEx(oXML,oXSL);
}

// SOURCE : http://developer.apple.com/internet/webcontent/xmlhttpreq.html
// EXAMPLE: http://developer.apple.com/internet/webcontent/XMLHttpRequestExample/example.html

// OTHER:
// http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=4079&lngWId=2

// MOST PROMOSING CROSS BROWSER CODE:
// http://www.experts-exchange.com/Web/Web_Languages/XML/Q_20986919.html

// retrieve XML document (reusable generic function);
// parameter is URL string (relative or complete) to
// an .xml file whose Content-Type is a valid XML
// type, such as text/xml; XML source must be from
// same domain as HTML file
function loadXMLDoc(url) 
{
  var req;
  

  // Branch for native XMLHttpRequest object
  if (window.XMLHttpRequest) 
  {
    req = new XMLHttpRequest();
    req.overrideMimeType('text/xml');
    //req.onreadystatechange = processReqChange;
    //req.open("GET", url, true);
    req.open("GET", url, false);
    req.send(null);
    // branch for IE/Windows ActiveX version
  }
  else if (window.ActiveXObject) 
  {

    // isIE = true;
    req = new ActiveXObject("Microsoft.XMLHTTP");
    if (req) 
    {
      //req.onreadystatechange = processReqChange;
      //req.open("GET", url, true);
      req.open("GET", url, false);
      req.send();
    }
  }
  
  //alert(req.status);
  
  return req.responseXML;
}

