title: Grouping/Paginating items from two different parents
body: <p>I'm a relative novice with XSLT, not having touched it since the late 90s, but I've recently started on a personal project that will involve it.</p>
  
  <p>I have the following XML, from which I'm attempting to build an HTML character sheet:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="./Statblock.xslt"?&gt;
  &lt;Character&gt;
   &lt;Name value="Seiyatomo"/&gt;
   &lt;Family value="Soshi"/&gt;
   &lt;Clan value="Scorpion"/&gt;
   &lt;School value="Soshi Illusionist School"/&gt;
   &lt;Titles/&gt;
   &lt;Ninjo value=""/&gt;
   &lt;Giri value=""/&gt;
   &lt;Abilities&gt;
    &lt;Ability description="" name="The Kami's Whisper" /&gt;
   &lt;/Abilities&gt;
   &lt;Skills&gt;
    ...
   &lt;/Skills&gt;
   &lt;Rings&gt;
    ...
   &lt;/Rings&gt;
   &lt;Social glory="50" honor="35" status="35"/&gt;
   &lt;Wealth bu="0" koku="6" zeni="0"/&gt;
   &lt;Derived composure="8" endurance="4" focus="4" vigilance="3"/&gt;
   &lt;RankStatus titlestatus="Title: , Title XP: 0" curricstatus="Rank: 1, XP in Rank: 0"/&gt;
   &lt;Curriculum&gt;
      ...
   &lt;/Curriculum&gt;
   &lt;Title/&gt;
   &lt;Techniques&gt;
    &lt;Technique name="Bō of Water" /&gt;
    &lt;Technique name="Cloak of Night" /&gt;
    &lt;Technique name="Token of Memory" /&gt;
    &lt;Technique name="Commune with the Spirits" /&gt;
    &lt;Technique name="All in Jest" /&gt;
    &lt;Technique name="Dangerous Allure" /&gt;
    &lt;Technique name="Shadowlands Taint (Water)" /&gt;
    &lt;Technique name="Curiosity" /&gt;
    &lt;Technique name="Dark Secret" /&gt;
    &lt;Technique name="Fallen Ancestor" /&gt;
   &lt;/Techniques&gt;
   &lt;PersonalTraits/&gt;
   &lt;Equipment&gt;
      ...
   &lt;/Equipment&gt;
   &lt;Heritage value="Glorious Sacrifice"/&gt;
   &lt;Notes value="..."/&gt;
   &lt;Advances/&gt;
   &lt;TotalXP value="0"/&gt;
   &lt;XPSpent value="0"/&gt;
   &lt;Portrait base64image=""/&gt;
  &lt;/Character&gt;
  </code></pre>
  
  <p>I am trying to group the combined list of Ability &amp; Technique nodes into sets of 9, such that I'll get output akin to this:</p>
  
  <pre><code>&lt;page&gt;
    &lt;ability&gt;The Kami's Whisper&lt;/ability&gt;
    &lt;technique&gt;Bō of Water&lt;/technique&gt;
    &lt;technique&gt;Cloak of Night&lt;/technique&gt;
    &lt;technique&gt;Token of Memory&lt;/technique&gt;
    &lt;technique&gt;Commune with the Spirits&lt;/technique&gt;
    &lt;technique&gt;All in Jest&lt;/technique&gt;
    &lt;technique&gt;Dangerous Allure&lt;/technique&gt;
    &lt;technique&gt;Shadowlands Taint (Water)&lt;/technique&gt;
    &lt;technique&gt;Curiosity&lt;/technique&gt;
  &lt;/page&gt;
  &lt;page&gt;
    &lt;technique&gt;Dark Secret&lt;/technique&gt;
    &lt;technique&gt;Fallen Ancestor&lt;/technique&gt;
  &lt;/page&gt;
  </code></pre>
  
  <p>The number of &lt;Ability&gt; and &lt;Technique&gt; nodes in the XML are arbitrary, but I would prefer that all &lt;ability&gt; nodes come first in the output, followed by the &lt;technique&gt; nodes.</p>
  
  <p>Bonus points, if that last &lt;page&gt; can be full of empty &lt;technique&gt; entries to fill the page out to the full set of 9, but that's a secondary concern.</p>
  
  <p>I tried searching for similar questions, but either I didn't see any that were quite like this, or I didn't understand the question/answers sufficiently to recognize them as duplicates.</p>
  
  <p>Note: It <em>may</em> be possible to get the author of the application which generates the XML to make some changes to the XML if necessary, but I can't directly control the XML itself.</p>