title: How to test if following-sibling tag has specific attribute value?
body: <p>Example xml:</p>
  
  <pre><code>&lt;body&gt;
  &lt;macroField dictTag="comment"&gt;&lt;/macroField&gt;
  &lt;macroField dictTag="comment"&gt;&lt;/macroField&gt;
  &lt;macroField dictTag="comment"&gt;&lt;/macroField&gt;
  &lt;macroField dictTag="comment"&gt;&lt;/macroField&gt;
  &lt;macroField dictTag="stopName"&gt;Old Wisconsin &lt;/macroField&gt;
  &lt;macroField dictTag="stopName"&gt;Another stop&lt;/macroField&gt;
  &lt;macroField dictTag="stopName"&gt;Another stop&lt;/macroField&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>I need to transform comments into divs but after the last comment I want to add extra
  text "STOPS: " before I show stop.</p>
  
  <p>I tried this xsl for comment tag but for some reason it evaluates to true for every comment tag, not just for the last one:</p>
  
  <pre><code>   &lt;xsl:template match="*[@dictTag = 'comment']"&gt;
      &lt;div class="comment_line"&gt;
          &lt;xsl:value-of select="."/&gt;
      &lt;/div&gt;
      &lt;xsl:if test="following-sibling::macroField/@dictTag = 'stopName'"&gt;
          &lt;p&gt;STOPS&lt;/p&gt;
      &lt;/xsl:if&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>What is wrong with my xsl:if test? How do I modify it so that if statement evaluates to true only for the last comment element?</p>