title: Outputting depth of current node in the hierarchy
body: <p>Using XSLT/XPATH 1.0, I want to create HTML where the <code>class</code> attribute of a <code>span</code> element indicates the depth in the original XML hierarchy.</p>
  
  <p>For example, with this XML fragment:</p>
  
  <pre><code>&lt;text&gt;
      &lt;div type="Book" n="3"&gt;
          &lt;div type="Chapter" n="6"&gt;
              &lt;div type="Verse" n="12"&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/text&gt;
  </code></pre>
  
  <p>I want this HTML:</p>
  
  <pre><code>&lt;span class="level1"&gt;Book 3&lt;/span&gt;
  &lt;span class="level2"&gt;Chapter 6&lt;/span&gt;
  &lt;span class="level3"&gt;Verse 12&lt;/span&gt;
  </code></pre>
  
  <p>How deep these <code>div</code> elements could go is not known a priori. The <code>div</code>s could be Book -> Chapter. They could be Volume -> Book -> Chapter -> Paragraph -> Line.</p>
  
  <p>I cannot rely on the values of @type. Some or all could be NULLs.</p>