title: Some help on how groupings actually work would be much appreciated
body: <p>I'm trying to get my head around how the different grouping techniques work. What causes a group, how are each group defined, and how the key are formed for each group.</p>
  
  <p>If I wanted to use "group-adjacent" to move all following siblings of a specific element name into the first of preceding sibling of a given type. Would this be doable? I know how I can do this with recursive templates, and to some extent with keys in xslt 1.0. But I cannot get the 2.0 groups to work for me.</p>
  
  <p>Lets say that I want to move all fig elements into the first preceding para, given that there are no other kinds of elements in between the fig(s) and the preceding para element, in this simple xml.</p>
  
  <pre><code>&lt;root&gt;
      &lt;first_lvl&gt;
          &lt;title&gt;First heading&lt;/title&gt;
          &lt;para&gt;First para under first heading&lt;/para&gt;
          &lt;para&gt;Second para under first heading&lt;/para&gt;
          &lt;fig&gt;fig1&lt;/fig&gt;
          &lt;fig&gt;fig 2&lt;/fig&gt;
          &lt;table&gt;Table A&lt;/table&gt;
          &lt;fig&gt;fig 3&lt;/fig&gt;
          &lt;para&gt;Third para under first heading&lt;/para&gt;
          &lt;para&gt;Fourth para under first heading&lt;/para&gt;
          &lt;fig&gt;fig4&lt;/fig&gt;
      &lt;/first_lvl&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>Desired result:</p>
  
  <pre><code>&lt;root&gt;
      &lt;first_lvl&gt;
          &lt;title&gt;First heading&lt;/title&gt;
          &lt;para&gt;First para under first heading&lt;/para&gt;
          &lt;para&gt;Second para under first heading
              &lt;fig&gt;fig1&lt;/fig&gt;
              &lt;fig&gt;fig 2&lt;/fig&gt;
          &lt;/para&gt;
          &lt;table&gt;Table A&lt;/table&gt;
          &lt;fig&gt;fig 3&lt;/fig&gt;
          &lt;para&gt;Third para under first heading&lt;/para&gt;
          &lt;para&gt;Fourth para under first heading
              &lt;fig&gt;fig4&lt;/fig&gt;
          &lt;/para&gt;
      &lt;/first_lvl&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>How can I set a grouping up that takes care of every directly following fig element?</p>
  
  <p>This doesn't work:</p>
  
  <pre><code>&lt;xsl:template match=para[following-sibling::*[1][self::fig]]&gt;
      &lt;xsl:for-each-group select"folowing-sibling::*" group-adjacent="boolean(self::fig)"&gt;
          &lt;xsl:apply-templates select="current-group()" mode="move"/&gt;
      &lt;/xsl:for-each-group&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>And then I've added atemplate to build content for each fig inside the para, and one to ignore those figs when they appear later on in the processing.</p>
  
  <p>No luck though.</p>
  
  <p>I have no other values to group by, other that the fact that they are fig elements.</p>
  
  <p>What am I missing here?</p>