Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 15th, 2013  |  syntax: None  |  size: 1.93 KB  |  views: 25  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <html>
  2. <head>
  3. <script>
  4. function loadXMLDoc(dname)
  5. {
  6. if (window.XMLHttpRequest)
  7.   {
  8.   xhttp=new XMLHttpRequest();
  9.   }
  10. else
  11.   {
  12.   xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  13.   }
  14. xhttp.open("GET",dname,false);
  15. xhttp.send("");
  16. return xhttp.responseXML;
  17. }
  18.  
  19. function displayResult()
  20. {
  21. xml=loadXMLDoc("f.xml");
  22. xsl=loadXMLDoc("xsl.xsl");
  23. // code for IE
  24. if (window.ActiveXObject)
  25.   {
  26.   ex=xml.transformNode(xsl);
  27.   document.getElementById("example").innerHTML=ex;
  28.   }
  29. // code for Mozilla, Firefox, Opera, etc.
  30. else if (document.implementation && document.implementation.createDocument)
  31.   {
  32.   xsltProcessor=new XSLTProcessor();
  33.   xsltProcessor.importStylesheet(xsl);
  34.  
  35.   xsltProcessor.setParameter(null, "testParam", "voo");
  36.   // alert(xsltProcessor.getParameter(null,"voc"));
  37.  
  38.   document.getElementById("example").innerHTML = "";
  39.  
  40.   resultDocument = xsltProcessor.transformToFragment(xml,document);
  41.   document.getElementById("example").appendChild(resultDocument);
  42.   }
  43.  
  44.  
  45. }
  46.  
  47. </script>
  48. </head>
  49. <body onload="displayResult()">
  50.     <li><u><a onclick="displayResult();" style="cursor: pointer;">test1</a></u></li>
  51. <div id="example" />
  52. </body>
  53. </html>
  54.        
  55. <?xml version="1.0" encoding="UTF-8"?>
  56. <?xml-stylesheet type="text/xsl" href="vocaroos.xsl"?>
  57. <test>
  58.     <artist name="Bert">
  59.         <voo>bert1</voo>
  60.     </artist>
  61.     <artist name="Pet">
  62.         <voo>pet1</voo>
  63.     </artist>
  64. </test>
  65.        
  66. <?xml version="1.0" encoding="ISO-8859-1"?>
  67. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  68.  
  69. <xsl:param name="testParam"/>
  70. <xsl:template match="/">
  71.   <html>
  72.   <body >
  73.   <h2>Titleee</h2>
  74.   <table border="1">
  75.     <tr bgcolor="#9acd32">
  76.       <th>Teeeeeest</th>
  77.     </tr>
  78.     <xsl:for-each select="test/artist">
  79.     <tr>
  80.       <td><xsl:value-of select="$testParam"/></td>
  81.     </tr>
  82.     </xsl:for-each>
  83.   </table>
  84.   </body>
  85.   </html>
  86. </xsl:template>
  87. </xsl:stylesheet>
  88.        
  89. <xsl:value-of select="$testParam"/>
  90.        
  91. <xsl:value-of select="voo"/>     (right outcome)