title: XSLT: Using variables in a key function
body: <p>I have a following XML file:</p>
  
  <pre><code>&lt;titles&gt;
     &lt;book title="XML Today" author="David Perry"/&gt;
     &lt;book title="XML and Microsoft" author="David Perry"/&gt;
     &lt;book title="XML Productivity" author="Jim Kim"/&gt;
     &lt;book title="XSLT 1.0" author="Albert Jones"/&gt;
     &lt;book title="XSLT 2.0" author="Albert Jones"/&gt;
     &lt;book title="XSLT Manual" author="Jane Doe"/&gt;
  &lt;/titles&gt;
  </code></pre>
  
  <p>I want to eliminate some elements and apply the following XSLT:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"&gt;
  
    &lt;xsl:output method="xml" indent="yes"/&gt;
  
    &lt;xsl:key name="author1-search" match="book[starts-with(@author, 'David')]" use="@title"/&gt;
    &lt;xsl:template match="book [key('author1-search', @title)]" /&gt;
  
    &lt;xsl:key name="author2-search" match="book[starts-with(@author, 'Jim')]" use="@title"/&gt;
    &lt;xsl:template match="book [key('author2-search', @title)]" /&gt;
  
    &lt;xsl:template match="/"&gt;  
      &lt;xsl:apply-templates /&gt;
    &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Is it possible to use an inline xsl variable </p>
  
  <pre><code>  &lt;xsl:variable name="Author"&gt; 
      &lt;name&gt;David&lt;/name&gt; 
      &lt;name&gt;Jim&lt;/name&gt; 
    &lt;/xsl:variable&gt; 
  </code></pre>
  
  <p>instead of "author1-search", "author2-search", and so on to loop through names?</p>
  
  <p>I can use only XSLT 1.0 (2.0 is currently not supported).</p>
  
  <p>Thanks in advance,</p>
  
  <p>Leo</p>