title: Using max in a variable in XSLT 1.0
body: <p>can I use max function in a variable in XSLT 1? 
  I need to find a maximum value inside some nodes and I'll need to call this from more places.
  So I tried to create a template:</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:msxsl="urn:schemas-microsoft-com:xslt"
   xmlns:essox="urn:essox-scripts"&gt;
      &lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/&gt;
      &lt;xsl:template name="Field001_max_dluznych_splatek"&gt;
          &lt;xsl:param name="CrRep"/&gt;
          &lt;xsl:variable name="PocetDluznychSplatekSplatky"&gt;
              &lt;xsl:value-of
               select="max($CrRep
                           /Response
                            /ContractData
                             /Installments
                              /InstDetail
                               /NrOfDueInstalments)" /&gt;
          &lt;/xsl:variable&gt;
          &lt;xsl:variable name="PocetDluznychSplatekKarty"&gt;
              &lt;xsl:value-of
               select="max($CrRep
                            /Response
                             /ContractData
                              /Cards
                               /CardDetail
                                /NrOfDueInstalments)" /&gt;
          &lt;/xsl:variable&gt;
          &lt;xsl:choose&gt;
              &lt;xsl:when test="$PocetDluznychSplatekSplatky
                               &amp;gt;= $PocetDluznychSplatekKarty"&gt;
                  &lt;xsl:value-of select="$PocetDluznychSplatekSplatky"/&gt;
              &lt;/xsl:when&gt;
              &lt;xsl:otherwise&gt;
                  &lt;xsl:value-of select="$PocetDluznychSplatekKarty"/&gt;
              &lt;/xsl:otherwise&gt;
          &lt;/xsl:choose&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>In XML Spy I get this error:</p>
  
  <blockquote>
    <p><code>Error in XPath expression Unknown
    function - Name and number of
    arguments do not match any function
    signature in the static context -
    'max'.</code></p>
  </blockquote>
  
  <p>What is wrong? 
  Thanks a lot,
  Peter</p>