title: Grouping of elements to new element based on attribute
body: <p>I need to group elements without an attribute into one new element. Depending on if the attribute @single the h2 should either be placed in a new container, or be places grouped with the h2s in sequence without @single. I'm struggling with the group for text 2,3,4. Do I need to create a template for h1 then us an xsl:for-each? Is there  a smarter way to do it?</p>
  
  <p>Source:</p>
  
  <pre><code>&lt;h1&gt;
      &lt;h2 single="true" /&gt;
      &lt;h2 single="true" /&gt;
      &lt;h2&gt;1&lt;/h2&gt;
      &lt;h2 single="true" /&gt;
      &lt;h2&gt;2&lt;/h2&gt;
      &lt;h2&gt;3&lt;/h2&gt;
      &lt;h2&gt;4&lt;/h2&gt;
      &lt;h2 single="true" /&gt;
      &lt;h2&gt;5&lt;/h2&gt;
  &lt;/h1&gt;
  </code></pre>
  
  <p>Result  </p>
  
  <pre><code>&lt;h1&gt;
      &lt;containertypeA&gt;
          &lt;h2 single="true" /&gt;
      &lt;/containertypeA&gt;
      &lt;containertypeA&gt;
          &lt;h2 single="true" /&gt;
      &lt;/containertypeA&gt;
      &lt;containertypeB&gt;
          &lt;h2&gt;1&lt;/h2&gt;
      &lt;/containertypeB&gt;
      &lt;containertypeA&gt;
          &lt;h2 single="true" /&gt;
      &lt;/containertypeA&gt;
      &lt;containertypeB&gt;
          &lt;h2&gt;2&lt;/h2&gt;
          &lt;h2&gt;3&lt;/h2&gt;
          &lt;h2&gt;4&lt;/h2&gt;
      &lt;/containertypeB&gt;
      &lt;containertypeA&gt;
          &lt;h2 single="true" /&gt;
      &lt;/containertypeA&gt;
      &lt;containertypeB&gt;
          &lt;h2&gt;5&lt;/h2&gt;
      &lt;/containertypeB&gt;
  &lt;/h1&gt;
  </code></pre>