title: How to process on values before sorting them?
body: <p>I previously posted <a href="https://stackoverflow.com/questions/22602178/how-to-sort-based-on-different-nodes"><strong>this question</strong></a> on this portal for which I got a satisfactory solution. Now my problem has evolved a bit. What if my XML in the linked question is updated so that my numbers have a unit associated with them like <code>cm</code>, <code>m</code>, <code>in</code>, <code>px</code> etc. So that the new XML is:</p>
  
  <pre><code>&lt;root&gt;
  &lt;a&gt;
      &lt;b&gt;12cm&lt;/b&gt;
      &lt;e&gt;hello&lt;/e&gt;
  &lt;/a&gt; 
  &lt;a&gt;
      &lt;b&gt;11m&lt;/b&gt;
      &lt;e&gt;how&lt;/e&gt;
  &lt;/a&gt;
  &lt;a&gt;
      &lt;c&gt;13m&lt;/c&gt;
      &lt;f&gt;are&lt;/f&gt;
  &lt;/a&gt;
  &lt;a&gt;
      &lt;b&gt;21cm&lt;/b&gt;
      &lt;f&gt;you&lt;/f&gt;
  &lt;/a&gt;
  &lt;a&gt;
      &lt;d&gt;22cm&lt;/d&gt;
      &lt;e&gt;hello&lt;/e&gt;
  &lt;/a&gt;
  &lt;a&gt;
      &lt;c&gt;14m&lt;/c&gt;
      &lt;f&gt;hi&lt;/f&gt;
  &lt;/a&gt;
  </code></pre>
  
  <p></p>
  
  <p>Now I would first need to transform theses numbers in a similar unit (lets say in <code>cm</code>) before I can sort them and find the maximum number. How can I do that?</p>
  
  <p>I used the following XSL for my previous problem but now I need to update it so that I am able to transform my numbers before sorting them.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0"&gt;
  &lt;xsl:output indent="yes" omit-xml-declaration="yes"/&gt;
  
  &lt;xsl:template match="root"&gt;
      &lt;xsl:for-each select="a/b | a/c | a/d"&gt;
          &lt;xsl:sort select="." order="descending"/&gt;   &lt;!-- find the unit and transform it in centimeters before sorting --&gt;
          &lt;xsl:if test="position() = 1"&gt;
              &lt;highest&gt;&lt;xsl:copy-of select="."/&gt;&lt;/highest&gt;
          &lt;/xsl:if&gt;
      &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p><strong>Note:</strong> I am using XSLT 1.0</p>