title: XSLT: ranking of elements and computation
body: <p>I apologize for being totally inexperienced with XML, but solving this problem will help me to understand how computation with XSLT works.</p>
  
  <p>We have a sample database structured like this:</p>
  
  <pre><code>&lt;HospitalML&gt;
  &lt;Patients&gt;
      &lt;Patient&gt;
          &lt;Name&gt;
              &lt;FirstName&gt;Salvatore&lt;/FirstName&gt;
              &lt;LastName&gt;Piscuoglio&lt;/LastName&gt;
          &lt;/Name&gt;
          &lt;Diagnoses&gt;
              &lt;Diagnosis&gt;
                  &lt;Name&gt;HCC&lt;/Name&gt;
                  &lt;Weight&gt;1.2&lt;/Weight&gt;
              &lt;/Diagnosis&gt;
              &lt;Diagnosis&gt;
                  &lt;Name&gt;CRC&lt;/Name&gt;
                  &lt;Weight&gt;2.2&lt;/Weight&gt;
              &lt;/Diagnosis&gt;
          &lt;/Diagnoses&gt;
      &lt;/Patient&gt;
  &lt;/Patients&gt;
  &lt;Hospitals&gt;
      &lt;Hospital&gt;
          &lt;HospitalName&gt;LondonGeneral&lt;/HospitalName&gt;
          &lt;Diagnoses&gt;
              &lt;Diagnosis&gt;
                  &lt;Name&gt;HCC&lt;/Name&gt;
                  &lt;Weight&gt;2.1&lt;/Weight&gt;
              &lt;/Diagnosis&gt;
              &lt;Diagnosis&gt;
                  &lt;Name&gt;CRC&lt;/Name&gt;
                  &lt;Weight&gt;0.2&lt;/Weight&gt;
              &lt;/Diagnosis&gt;
          &lt;/Diagnoses&gt;
      &lt;/Hospital&gt;
      &lt;Hospital&gt;
          &lt;HospitalName&gt;EastEnd&lt;/HospitalName&gt;
          &lt;Diagnoses&gt;
              &lt;Diagnosis&gt;
                  &lt;Name&gt;HCC&lt;/Name&gt;
                  &lt;Weight&gt;1.7&lt;/Weight&gt;
              &lt;/Diagnosis&gt;
              &lt;Diagnosis&gt;
                  &lt;Name&gt;CRC&lt;/Name&gt;
                  &lt;Weight&gt;0.7&lt;/Weight&gt;
              &lt;/Diagnosis&gt;
          &lt;/Diagnoses&gt;
      &lt;/Hospital&gt;
  &lt;/Hospitals&gt;
  </code></pre>
  
  <p></p>
  
  <p>Each patient has a set of diagnoses with "weight" values indicating how severe they are. 
  Each hospital element has "diagnoses"child elements indicating which diseases they manage and a "weight" element scores indicating how good they are at each. </p>
  
  <p>I would like to evaluate hospitals from the database for patient Salvatore and give a list of hospitals ranked up by scores indicating the best ones for his diagnoses.</p>
  
  <p>Would be grateful for any thoughts. Thanks.</p>