title: find next-to-last node with xpath
body: <p>I have a XML document with <code>chapters</code> and nested <code>sections</code>.
  I am trying to find, for any section, the first second-level section ancestor.
  That is the next-to-last section in the <code>ancestor-or-self</code> axis.
  pseudo-code:</p>
  
  <pre><code>&lt;chapter&gt;&lt;title&gt;mychapter&lt;/title&gt;
    &lt;section&gt;&lt;title&gt;first&lt;/title&gt;
       &lt;section&gt;&lt;title&gt;second&lt;/title&gt;
         &lt;more/&gt;&lt;stuff/&gt;
       &lt;/section&gt;
    &lt;/section&gt;
  &lt;/chapter&gt;
  </code></pre>
  
  <p>my selector:</p>
  
  <pre><code>&lt;xsl:apply-templates 
      select="ancestor-or-self::section[last()-1]" mode="title.markup" /&gt;
  </code></pre>
  
  <p>Of course that works until last()-1 isn't defined (the current node is the <code>first</code> section).</p>
  
  <p>If the current node is below the <code>second</code> section, i want the title <code>second</code>. 
  Otherwise I want the title <code>first</code>.  </p>