title: XSL: passing variables between templates
body: <p>Is it possible to pass a variable from one parent template to its child element ?</p>
  
  <pre><code>&lt;xsl:template match="structure"&gt;
    &lt;xsl:variable name="var"&gt;&lt;xsl:value-of select="@path" /&gt;&lt;/xsl:variable&gt;
    &lt;xsl:apply-templates select="folders"&gt;
      &lt;xsl:with-param name="var1" select="'{var}'"/&gt;
    &lt;/xsl:apply-templates&gt;
  &lt;/xsl:template&gt; 
  </code></pre>
  
  <p>this template will match:</p>
  
  <pre><code>&lt;xsl:template match="folder"&gt;
    &lt;xsl:param name="var1"/&gt;
    &lt;xsl:value-of select="$var1"/&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>You see I wanna use var as var1 in the matched template.</p>
  
  <p>How can I make this work?</p>
  
  <p>edit:
  the structure is like this:</p>
  
  <pre><code>&lt;structure path="C:\xampplite\htdocs\xampp"&gt;
    &lt;folders&gt;
      &lt;folder name="img"&gt;
        &lt;date&gt;01/28/10 21:59:00&lt;/date&gt;
        &lt;size&gt;37.4 KB&lt;/size&gt;
      &lt;/folder&gt;
   &lt;/folders&gt;
  &lt;/structure&gt;
  </code></pre>
  
  <p>edit2:</p>
  
  <pre><code>&lt;xsl:template match="folder"&gt;
  &lt;xsl:variable name="var1"&gt;&lt;xsl:value-of select="../../@path"/&gt;&lt;/xsl:variable&gt;
  &lt;xsl:variable name="var2"&gt;&lt;xsl:value-of select="@name" /&gt;&lt;/xsl:variable&gt;
  &lt;xsl:variable name="var3"&gt;&lt;xsl:value-of select="$var1"/&gt;\&lt;xsl:copy-of select="$var2"/&gt;    &lt;/xsl:variable&gt;
   &lt;th colspan="2" align="left"  bgcolor="#FF5500"&gt;&lt;a onclick="foo('{$var3}')"&gt;&lt;xsl:value-of select="$var3"/&gt;&lt;/a&gt;&lt;/th&gt;
  </code></pre>
  
  <p>in the jscript function the string is without its backslashes. anyone knows why?</p>
  
  <p>C:xampplitehtdocsxamppimg</p>