title: XPath - assign a value to variable and use it later
body: <p>Does XPath supports the concept of variables?</p>
  
  <p>My use case is when I need to use one long XPath expression a few times inside one experession.</p>
  
  <p>For instance in XPath 1.0 (where there's no <code>lower-case()</code> function), I want to evaluate the lower case of a string and use it inside the expression. Instead of writing:</p>
  
  <pre><code>//*[
        contains(
             @text, 
             translate(
                  'My String', 
                  'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 
                  'abcdefghijklmnopqrstuvwxyz'
             )
        )
        and not (
             ./descendant::*[
             contains(
                  @text, 
                  translate(
                       'Some String', 
                       'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 
                       'abcdefghijklmnopqrstuvwxyz'
                  )
             ]
        )
   ] 
  </code></pre>
  
  <p>I want to write something like:</p>
  
  <pre><code> $myLowerCaseString = translate(
        'My String', 
        'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 
        'abcdefghijklmnopqrstuvwxyz'
   )
   //*[
        contains(
             @text, 
             $myLowerCaseString
        )
        and not (
             ./descendant::*[
             contains(
                  @text, 
                  $myLowerCaseString
             ]
        )
   ] 
  </code></pre>
  
  <p>(NOTE: This scenario may have a different solution. and I'm looking for a general solution for scenarios that uses the same complicated String/Boolean/Node/NodeSet evaluation several times).</p>