I'm having a problem with a xsl transformation on a extended xml JUnit report file. I've extended the file as follows:
<testcase classname="net.luminis.osgitest.test.adhoc.AdHocTest" name="testGetExportedPackagesByPackage" osgi-vendor-name="felix/1.8.0" time="3.212">
<osgi-specs>
  <osgi-spec version="4.1">
    <sections>
      <section>3.5.5</section>
    </sections>
  </osgi-spec>
  <osgi-spec version="4.2">
    <sections>
      <section>3.5.6</section>
    </sections>
  </osgi-spec>
</osgi-specs>
The osgi-specs node (and subnodes) in the testcase corresponds to a section overview file:
<versions>
  <version name="4.1" id="41">
    <sections>
      <section id="12" number="2" name="Security Layer">
        <sections>
          <section id="13" number="2.1" name="Introduction" parent="12">
            <sections>
              <section id="14" number="2.1.1" name="Essentials" parent="13" />
            </sections>
          </section>
        </sections>
      </section>
      <!-- some more sections with subsections -->
    </sections>
  </version>
  <version name="4.2" id="42">
    <!-- some more sections with subsections -->
  </version>
</version>
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 http://opensource.luminis.net/svn/OSGITESTRESULTS/trunk/index.html
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:
//testcase[@osgi-vendor-name=$osgi.vendor.name]//osgi-spec[@version=$osgi.version.name]//section[starts-with(text(), $osgi.section.number)]/../../../..
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?