title: XSLT Pass parameter
body: <p>I've been looking at other questions but I can't quite see what I'm doing wrong.
  I want to pass a parameter to select certain results only, but I'm having problems with the parameter. </p>
  
  <p>The html (disregard the IE part)</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script&gt;
  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("f.xml");
  xsl=loadXMLDoc("xsl.xsl");
  // code for IE
  if (window.ActiveXObject)
    {
    ex=xml.transformNode(xsl);
    document.getElementById("example").innerHTML=ex;
    }
  // code for Mozilla, Firefox, Opera, etc.
  else if (document.implementation &amp;&amp; document.implementation.createDocument)
    {
    xsltProcessor=new XSLTProcessor();
    xsltProcessor.importStylesheet(xsl);
  
    xsltProcessor.setParameter(null, "testParam", "voo");
    // alert(xsltProcessor.getParameter(null,"voc"));
  
    document.getElementById("example").innerHTML = "";
  
    resultDocument = xsltProcessor.transformToFragment(xml,document);
    document.getElementById("example").appendChild(resultDocument);
    }
  
  
  }
  
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onload="displayResult()"&gt;
      &lt;li&gt;&lt;u&gt;&lt;a onclick="displayResult();" style="cursor: pointer;"&gt;test1&lt;/a&gt;&lt;/u&gt;&lt;/li&gt;
  &lt;div id="example" /&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="vocaroos.xsl"?&gt;
  &lt;test&gt;
      &lt;artist name="Bert"&gt;
          &lt;voo&gt;bert1&lt;/voo&gt;
      &lt;/artist&gt;
      &lt;artist name="Pet"&gt;
          &lt;voo&gt;pet1&lt;/voo&gt;
      &lt;/artist&gt;
  &lt;/test&gt;
  </code></pre>
  
  <p>xsl</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  
  &lt;xsl:param name="testParam"/&gt;
  &lt;xsl:template match="/"&gt;
    &lt;html&gt;
    &lt;body &gt;
    &lt;h2&gt;Titleee&lt;/h2&gt;
    &lt;table border="1"&gt;
      &lt;tr bgcolor="#9acd32"&gt;
        &lt;th&gt;Teeeeeest&lt;/th&gt;
      &lt;/tr&gt;
      &lt;xsl:for-each select="test/artist"&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;xsl:value-of select="$testParam"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;/xsl:for-each&gt;
    &lt;/table&gt;
    &lt;/body&gt;
    &lt;/html&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt; 
  </code></pre>
  
  <p>Here is the outcome (left)</p>
  
  <p><img src="https://i.stack.imgur.com/bIwC0.jpg" alt="outcome"></p>
  
  <p>On the left is what this does and on the right, what I actually want. I was expecting that </p>
  
  <pre><code>&lt;xsl:value-of select="$testParam"/&gt;
  </code></pre>
  
  <p>would do the same as</p>
  
  <pre><code>&lt;xsl:value-of select="voo"/&gt;     (right outcome)
  </code></pre>
  
  <p>since I do setParameter(null, "testParam", "voo"); in the html, but for some reason the xsl doesn't use "voo" as select, but instead writes "voo".</p>
  
  <p>I've been trying different things but nothing works. Where's the mistake?</p>