title: XSLT key() lookup
body: <p>I'm trying out a sample of look-up tables in XSLT and am not able to get it to work</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 method="xml" /&gt;
     &lt;xsl:key name="classification-lookup" match="classification" use="id" /&gt;
     &lt;xsl:variable name="classification-top" select="document('')/*/classifications" /&gt;
     &lt;xsl:template match="BusinessListing"&gt;
        &lt;listing&gt;
           &lt;id&gt;
              &lt;xsl:value-of select="id" /&gt;
           &lt;/id&gt;
           &lt;xsl:apply-templates select="$classification-top"&gt;
              &lt;xsl:with-param name="curr-label" select="." /&gt;
           &lt;/xsl:apply-templates&gt;
        &lt;/listing&gt;
     &lt;/xsl:template&gt;
     &lt;xsl:template match="classifications"&gt;
        &lt;xsl:param name="curr-label" /&gt;
        &lt;category&gt;
           &lt;xsl:value-of select="key('classification-lookup', $curr-label/listingData/classifications/classificationId)/description" /&gt;
        &lt;/category&gt;
     &lt;/xsl:template&gt;
     &lt;classifications&gt;
        &lt;classification&gt;
           &lt;id&gt;7981&lt;/id&gt;
           &lt;description&gt;Category1&lt;/description&gt;
        &lt;/classification&gt;
        &lt;classification&gt;
           &lt;id&gt;7982&lt;/id&gt;
           &lt;description&gt;Category2&lt;/description&gt;
        &lt;/classification&gt;
        &lt;classification&gt;
           &lt;id&gt;7983&lt;/id&gt;
           &lt;description&gt;Category3&lt;/description&gt;
        &lt;/classification&gt;
        &lt;classification&gt;
           &lt;id&gt;7984&lt;/id&gt;
           &lt;description&gt;Category4&lt;/description&gt;
        &lt;/classification&gt;
     &lt;/classifications&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>and the source is as below .</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;BusinessListings&gt;
  &lt;BusinessListing&gt;
      &lt;id&gt;1593469&lt;/id&gt;
      &lt;listingData&gt;
          &lt;classifications&gt;
              &lt;classificationId&gt;7982&lt;/classificationId&gt;
              &lt;classificationId&gt;7983&lt;/classificationId&gt;
          &lt;/classifications&gt;
      &lt;/listingData&gt;
  &lt;/BusinessListing&gt;
  &lt;/BusinessListings&gt;
  </code></pre>
  
  <p>In the result below , The category is empty but I need the Classification Id from the source to be matched with the id in the classification tag and the category generated .</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;listing&gt;
  &lt;id&gt;1593469&lt;/id&gt; -- Empty I need the Category2 and Category3 here
  &lt;category/&gt;
  &lt;/listing&gt;
  </code></pre>
  
  <p>I know that I may be wide off mark but I've just started off with XSLT and referred the sample here <a href="http://www.ibm.com/developerworks/xml/library/x-xsltip.html" rel="nofollow">http://www.ibm.com/developerworks/xml/library/x-xsltip.html</a> . Thanks for the help .</p>