Writing D:/inetpub/webs/vincenzodevivocom/wiki/data/cache/d/d7107f5dfba7e0611ac0acc92040bf80.i failed
Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.
Writing D:/inetpub/webs/vincenzodevivocom/wiki/data/cache/d/d7107f5dfba7e0611ac0acc92040bf80.i failed
Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.
Writing D:/inetpub/webs/vincenzodevivocom/wiki/data/cache/d/d7107f5dfba7e0611ac0acc92040bf80.xhtml failed

XSL Tranformation

XSL Tranformation Editor:

XML
XSL


Result

Javascript Code

transform.js
function encHtml(s){
	s = s.replace(/</g,"@@@@newLine@@@@&lt;");
	s = s.replace(/\'/g,"&#39;"); //no HTML equivalent as &apos is not cross browser supported
	s = s.replace(/\"/g,"&quot;");
	s = s.replace(/>/g,"&gt;");
	s = s.replace(/</g,"&lt;");
 
	if (window.ActiveXObject)// Internet Explorer
	{
		s = s.replace(/@@@@newLine@@@@/g,"<br>");
	}else{
		s = s.replace(/@@@@newLine@@@@/g,"\n");
	}
 
	return s;
}
function transform(){
	document.getElementById("result").innerHTML="";
	var xml = document.getElementById("xml").value;
	var xsl = document.getElementById("xsl").value;
	var result = "";
	if(xml && xsl){
		if (window.ActiveXObject)// Internet Explorer
			{
				var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
				var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
				xmlDoc.loadXML(xml);
				xslDoc.loadXML(xsl);
			}
		else if (window.DOMParser)
			{
				var parser=new DOMParser();
				xmlDoc=parser.parseFromString(xml,"text/xml");
				xslDoc=parser.parseFromString(xsl,"text/xml");
			}
 
		try{
			// code for IE
			if (window.ActiveXObject)
			  {
				var xslt = new ActiveXObject("Msxml2.XSLTemplate");
 
				xslt.stylesheet = xslDoc;
				var xslProc = xslt.createProcessor();
				xslProc.input = xmlDoc;
				xslProc.transform();
				result=xslProc.output;
				document.getElementById("result").innerHTML=encHtml(result);  
			  }
			// code for Mozilla, Firefox, Opera, etc.
			else if (document.implementation && document.implementation.createDocument)
			{
 
				xsltProcessor=new XSLTProcessor();
				xsltProcessor.importStylesheet(xslDoc);
				result = xsltProcessor.transformToFragment(xmlDoc,document);
				var nodeRes = document.getElementById("result");
				nodeRes.appendChild(result);
				nodeRes.innerHTML = encHtml(nodeRes.innerHTML);
			}
		}
		catch(e){
				result = "Error: " + e;
				document.getElementById("result").innerHTML=encHtml(result);
		}	
	}
}
 
code/js/xsl_tranformation.txt · Last modified: 2012/04/06 15:33 by Vincenzo De Vivo
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki