title: How to iterate through multiple-node structures in XSL
body: <p>I need to iterate through multiple-node structures, but this structure is only identified by the leading node, and the nodes following that leading node can vary. </p>
  
  <p>In this example, I need to iterate through each <code>&lt;title&gt;-some_nodes</code>, <code>&lt;title&gt;-some_other_nodes</code> block</p>
  
  <p>XML file:</p>
  
  <pre><code>&lt;books&gt;
      &lt;title&gt;book_one&lt;/title&gt;
      &lt;price&gt;price_for_book_one&lt;/price&gt;
      &lt;notes&gt;notes_for_book_one&lt;/notes&gt;
  
      &lt;title&gt;book_two&lt;/title&gt;
      &lt;price&gt;price_for_book_two&lt;/price&gt;
  &lt;/books&gt;
  </code></pre>
  
  <p>Desired output:</p>
  
  <pre><code>&lt;div class="book"&gt;
      &lt;h1 id="title"&gt;book_one&lt;/h1&gt;
      &lt;h2 id="values"&gt;
          &lt;p&gt;price_for_book_one&lt;/p&gt;
          &lt;p&gt;notes_for_book_one&lt;/p&gt;
      &lt;/h2&gt;
  &lt;/div&gt;
  
  &lt;div class="book"&gt;
      &lt;h1 id="title"&gt;book_two&lt;/h1&gt;
      &lt;h2 id="values"&gt;
          &lt;p&gt;price_for_book_two&lt;/p&gt;
      &lt;/h2&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My try:</p>
  
  <pre><code>&lt;xsl:template match="/"&gt;
      &lt;xsl:for-each select="books/title"&gt;
          &lt;h1 id="title"&gt;&lt;xsl:text&gt;Title:&lt;/xsl:text&gt;
              &lt;xsl:value-of select="." /&gt;
          &lt;/h1&gt;
  
          &lt;h2 id="values"&gt;    
          &lt;!-- have other templates for matching all possible following-sibling nodes --&gt;
              &lt;xsl:apply-templates select="following-sibling::*&gt;
          &lt;/h2&gt;
      &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>But this only selects the title nodes without parsing any other nodes, since "books/title" only selects the title node.</p>
  
  <p>Note: <code>&lt;price&gt;</code> and <code>&lt;notes&gt;</code> are two example nodes, there could be anything in between the <code>&lt;title&gt;</code> nodes, and I have other templates for dealing with them, but how to select them is the my problem.</p>
  
  <p>Any thoughts would be greatly appreciated.</p>