title: Defining and using variables in XSL
body: <p>I have an xsl file with variables and parameters. Parameters are defined in another xml file:</p>
  
  <pre><code>&lt;fo:block&gt;&lt;xsl:value-of select="root/period"/&gt;&lt;/fo:block&gt;
  </code></pre>
  
  <p>and the parameter has the value:</p>
  
  <pre><code>&lt;root&gt;
    &lt;period&gt;1-5&lt;/period&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>Now, sometimes I want to display the block, containing the period, sometimes I don't. How can I achieve this? Here is how I tried:</p>
  
  <pre><code>&lt;xsl:variable name="cond" select="root/cond"/&gt;
  &lt;xsl:if test="$cond='1'"&gt;
    &lt;fo:block&gt;&lt;xsl:value-of select="root/period"/&gt;&lt;/fo:block&gt;
  &lt;/xsl:if&gt;
  </code></pre>
  
  <p>parameters:</p>
  
  <pre><code>&lt;root&gt;
    &lt;cond&gt;1&lt;/cond&gt;
    &lt;period&gt;1-5&lt;/period&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>This does not work!
  I displayed the value of the variable using <code>&lt;xsl:copy-of select="$cond" /&gt;</code> and it's empty.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I know now what the problem is:</p>
  
  <p><strong>xsl-fo:</strong></p>
  
  <pre><code>&lt;fo:flow flow-name="xsl-region-body"&gt;
    &lt;fo:block&gt;
      test
    &lt;/fo:block&gt;
    &lt;fo:block&gt;
      &lt;xsl:variable name="cond" select=root/cond/&gt;
      &lt;xsl:copy-of select="$cond" /&gt;
    &lt;/fo:block&gt;
    &lt;fo:block&gt;
      &lt;xsl:value-of select="root/period"/&gt;
    &lt;/fo:block&gt;
  &lt;/fo:flow&gt;
  </code></pre>
  
  <p><strong>parameters:</strong></p>
  
  <pre><code>&lt;root&gt;
    &lt;cond&gt;haha&lt;/cond&gt;
    &lt;period&gt;01.01.2013 – 31.12.2013&lt;/period&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p><strong>output:</strong></p>
  
  <p>test
  01.01.2013 – 31.12.2013</p>
  
  <p>So the question is really: how can I select a value from the xml parameters and assign the value to a xsl variable?</p>