XSL file handling through javascript

jcldjgbfilj

New Member
i want to handle my xsl file through my javascript code. I made my XSL file but i want to dynamically change my XSL file at run time.As in add more attributes in header or data.My javascript code as follow`\[code\]<script>function loadXMLDoc(dname){if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest(); }else { xhttp=new ActiveXObject("Microsoft.XMLHTTP"); }xhttp.open("GET",dname,false);xhttp.send("");return xhttp.responseXML;}function displayResult(){xml=loadXMLDoc("cdcatalog.xml");xsl=loadXMLDoc("cdcatalog.xsl");// code for IEif (window.ActiveXObject) { ex=xml.transformNode(xsl); document.getElementById("example").innerHTML=ex; }// code for Mozilla, Firefox, Opera, etc.else if (document.implementation && document.implementation.createDocument) { xsltProcessor=new XSLTProcessor(); xsltProcessor.importStylesheet(xsl); resultDocument = xsltProcessor.transformToFragment(xml,document); document.getElementById("example").appendChild(resultDocument); }}</script>\[/code\]\[code\]My XSL file code:\[/code\]\[code\]<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"> <html> <body> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th align="left">Title</th> <th align="left">Artist</th> <th align="left">Country</th> </tr> <xsl:for-each select="catalog/cd"> <tr> <td><xsl:value-of select="title" /></td> <td><xsl:value-of select="artist" /></td> <td><xsl:value-of select="country" /></td> </tr> </xsl:for-each> </table> </body> </html></xsl:template></xsl:stylesheet>\[/code\]`
 
Back
Top