title: Better usage or alternative for starts-with in xpath
body: <p>I'm having a problem with a xsl transformation on a extended xml JUnit report file. I've extended the file as follows:</p>
  
  <pre><code>&lt;testcase classname="net.luminis.osgitest.test.adhoc.AdHocTest" name="testGetExportedPackagesByPackage" osgi-vendor-name="felix/1.8.0" time="3.212"&gt;
  &lt;osgi-specs&gt;
    &lt;osgi-spec version="4.1"&gt;
      &lt;sections&gt;
        &lt;section&gt;3.5.5&lt;/section&gt;
      &lt;/sections&gt;
    &lt;/osgi-spec&gt;
    &lt;osgi-spec version="4.2"&gt;
      &lt;sections&gt;
        &lt;section&gt;3.5.6&lt;/section&gt;
      &lt;/sections&gt;
    &lt;/osgi-spec&gt;
  &lt;/osgi-specs&gt;
  </code></pre>
  
  <p></p>
  
  <p>The osgi-specs node (and subnodes) in the testcase corresponds to a section overview file:</p>
  
  <pre><code>&lt;versions&gt;
    &lt;version name="4.1" id="41"&gt;
      &lt;sections&gt;
        &lt;section id="12" number="2" name="Security Layer"&gt;
          &lt;sections&gt;
            &lt;section id="13" number="2.1" name="Introduction" parent="12"&gt;
              &lt;sections&gt;
                &lt;section id="14" number="2.1.1" name="Essentials" parent="13" /&gt;
              &lt;/sections&gt;
            &lt;/section&gt;
          &lt;/sections&gt;
        &lt;/section&gt;
        &lt;!-- some more sections with subsections --&gt;
      &lt;/sections&gt;
    &lt;/version&gt;
    &lt;version name="4.2" id="42"&gt;
      &lt;!-- some more sections with subsections --&gt;
    &lt;/version&gt;
  &lt;/version&gt;
  </code></pre>
  
  <p>With these two xml files I generate an HTML table to display a section overview (per version) and a mark to show if the testresults succeeded (per osgi-vendor) with a xsl transformation. See the current version at <a href="http://opensource.luminis.net/svn/OSGITESTRESULTS/trunk/index.html" rel="nofollow noreferrer">http://opensource.luminis.net/svn/OSGITESTRESULTS/trunk/index.html</a></p>
  
  <p>Now. I'm having the following problem. Sometimes I have a test with 3.5.5.1 as section number. But the section overview file only goes as deep as 3.5.5. So I want to display the test under the section 3.5.5. I tried this with xpath using something like this:</p>
  
  <pre><code>//testcase[@osgi-vendor-name=$osgi.vendor.name]//osgi-spec[@version=$osgi.version.name]//section[starts-with(text(), $osgi.section.number)]/../../../..
  </code></pre>
  
  <p>With this, I select all the testcases that corresponds to some section in a specific with a specific version and vendor. The problem is, when putting this expression in a for-each the testcase with section 3.5.5.1 is also shown in section 3, 3.5 end so on, but I only want it to show up in the most accurate section possible. (3.5.5) I'm not that familiar with xsl/xpath and I don't know if this can be achieved with one single xpath expression in a for-each. If so. What kind of expression do I need? If not. What is the best alternative?</p>