title: change variable value in xsl
body: <p>I'm having a problem with XSL variables.
  I know that once declared, the value of the variable cant be changed.</p>
  
  <p>But I'm facing a rather strange problem and I cant possibly change the XML output, instead figure out if its possible with XSL itself.</p>
  
  <p>I'm using xsl:for-each to loop over some data in the XML.</p>
  
  <p>The data being looped can be of three types, say Type1, Type2 and Type3</p>
  
  <p>If it is of Type1, I'm calling a template to process that data. Inside the template I'm displaying a header. I need to print this header for the very first time I'm encountering this Type1 data only. After that I dont need to display this. </p>
  
  <p>I could've passed a parameter along with the call-template and set/unset it to determine if I need to print the header text. But as I understand, being a formatting language, the variable state is not preserved.</p>
  
  <p>Can you please provide your valuable suggestions on how to implement this(possibly without xml changes)?</p>
  
  <p>Edit:</p>
  
  <p>The test  will work for the XML output mentioned by Patrice. But my XML is different. </p>
  
  <pre><code>&lt;doc&gt; 
  &lt;item&gt;foobar&lt;/item&gt; 
  &lt;item&gt;foo&lt;/item&gt; 
  &lt;item&gt;bar&lt;/item&gt; 
  &lt;item&gt;baz&lt;/item&gt; 
  &lt;item&gt;foo&lt;/item&gt; 
  &lt;item&gt;bar&lt;/item&gt; 
  &lt;/doc&gt; 
  </code></pre>
  
  <p>From this XML, I need to display a header for the very first time it encounters 'foo'. The order of items could be anything too. I cannot exactly predict when 'foo' will appear in the XML. </p>
  
  <p>Can you please bring up any suggestions?</p>