/* tide.js * Opción 1: Incluir la hoja de estilos en el xml y llamar al xml en un iframe * Inconveniente. Las funciones extendidas del xsl no funcionan en Firefox * <?xml-stylesheet type="text/xsl" href="tides.xsl"?> * <iframe frameborder="0" scrolling="no" src="tides.xml"/> * Opción 2: Llamar a un javascript que abra los documentos xml y xsl y aplique la transformación * En vez de usar un parámetro en el xsl (no sé cómo pasarlo al xsl) se modifica un atributo del propio xml * para usarlo en la condición del xsl. * Inconveniente no aplica el css del xsl en IE * <script type="text/javascript" src='tides.js'></script> */var xmlFile = "/js/tides.xml";var xslFile = "/js/tides.xsl";var strId = "tides-info";displayResult(xmlFile, xslFile, strId);function displayResult(xmlFile, xslFile, strId){	xml = loadXMLDoc(xmlFile);	//x = xml.getElementsByTagName("CurrentDate")[0].childNodes[0];	//x.nodeValue="2010-11-10";	x = xml.getElementsByTagName("Root");    x[0].setAttribute("CurrentDate", currentDate()); 	xsl = loadXMLDoc(xslFile);	if (window.ActiveXObject) 	// code for IE	{	  ex = xml.transformNode(xsl);	  // La siguiente línea funciona si el id está definido antes de llamar a este script	  document.getElementById(strId).innerHTML=ex;	  //document.write(ex);	  //alert("IE");	}	// code for Firefox, Opera, etc.	else if (document.implementation && document.implementation.createDocument)	{	  xsltProcessor = new XSLTProcessor();	  xsltProcessor.importStylesheet(xsl);	  resultDocument = xsltProcessor.transformToFragment(xml,document);	  document.getElementById(strId).appendChild(resultDocument);	  //alert("no IE");	}}function loadXMLDoc(file){	if (window.XMLHttpRequest)	{	  xhttp = new XMLHttpRequest();	}	else	{	  xhttp = new ActiveXObject("Microsoft.XMLHTTP");	}	xhttp.open("GET", file, false);	xhttp.send("");	return xhttp.responseXML;}function currentDate(){  var date = new Date();  var day = date.getDate();  var month = date.getMonth();  var year = date.getFullYear();  if (day < 10) day = "0" + day;  ++month;  if (month < 10) month = "0" + month;  return year + "-" + month + "-" + day;}
