title: Merge adjacent sibling nodes with XSLT
body: <p>I have a question that caused me a terrible headache. Please help me. The input is:</p>
  
  <pre><code>&lt;body&gt;
   &lt;p class="section"&gt; section 1 &lt;/p&gt;
   &lt;p class="code"&gt; some code &lt;/p&gt;
   &lt;p class="code"&gt; following code &lt;/p&gt;
   &lt;p class="code"&gt; following code &lt;/p&gt;
   &lt;p class="section"&gt; section 2 &lt;/p&gt;
   &lt;p class="code"&gt; other code &lt;/p&gt;
   &lt;p class="code"&gt; following code &lt;/p&gt;
   &lt;p class="code"&gt; following code &lt;/p&gt;
   &lt;p class="section"&gt; section 3 &lt;/p&gt;
   &lt;p class="code"&gt; still other code &lt;/p&gt;
   &lt;p class="code"&gt; following &lt;/p&gt;
   &lt;p class="code"&gt; following &lt;/p&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>The output I'd like:</p>
  
  <pre><code>&lt;body&gt;
   &lt;p class="section"&gt; section 1 &lt;/p&gt;
   &lt;pre&gt; some code following code following code &lt;/pre&gt;
   &lt;p class="section"&gt; section 2 &lt;/p&gt;
   &lt;pre&gt; other code following code following code &lt;/pre&gt;
   &lt;p class="section"&gt; section 3 &lt;/p&gt;
   &lt;pre&gt; still other code following following &lt;/pre&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>The problem is to collapse to a <code>&lt;pre&gt;</code> tag all adjacent <code>&lt;p class="code"&gt;</code> tags. Don't find a way to do this using XSLT. Do you think a solution exists?</p>