title: XSL - Embedded Lookup Table - Lookup Value of Variable
body: <p>StackExchange, I'm hoping someone here can help me with this issue!</p>
  
  <p>I'm working in <strong>XSLT 1.0</strong>, trying to embed a lookup table to convert some unformatted data to a standardized, formatted structure.</p>
  
  <p>I have read and searched and tried various methods to accomplish this and none of them have been able to generate a result. (Though I'm not getting any errors, either.)</p>
  
  <p>Below is a sample of the XSL I'm working with:</p>
  
  <pre><code>&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
                  xmlns:lookup="lookup" exclude-result-prefixes="lookup"&gt;
  
  &lt;xsl:key name="lookup_table" match="lookup:table/row" use="@raw"/&gt;
  
  &lt;lookup:table&gt;
      &lt;row raw="raw1" corrected="Raw One"/&gt;
      &lt;row raw="raw2" corrected="Raw Two"/&gt;
      &lt;row raw="raw3" corrected="Raw Three"/&gt;
      &lt;row raw="raw4" corrected="Raw Four"/&gt;
      &lt;row raw="raw5" corrected="Raw Five"/&gt;
  &lt;/lookup:table&gt;
  
  &lt;xsl:template match="/"&gt;
  
  &lt;xsl:variable name="lookup_table" select='document("")//lookup:table/row'/&gt;
  &lt;xsl:variable name="value_to_lookup" select="'raw1'"/&gt;
  
          &lt;!-- In the actual XSL document, this variable would use an XPath to point to another attribute. --&gt;
          &lt;!-- In this case, the value of this variable must be changed manually. --&gt;
  
  &lt;xsl:value-of select='document("")//lookup:table/row[@raw = $value_to_lookup]/@corrected'/&gt;
  
  &lt;xsl:value-of select='document("")//lookup:table[@raw = $value_to_lookup]/@corrected'/&gt;
  
  &lt;xsl:value-of select='$lookup_table[@raw = $value_to_lookup]/@corrected'/&gt;
  
  &lt;xsl:value-of select="key('lookup_table',$value_to_lookup)/@corrected"/&gt;
  
      &lt;!-- The above lines are the various methods I've seen documented on other websites that claim these methods should allow me to what I need to. --&gt;
      &lt;!-- There is no need to have multiple identical results, I only have multiple attempts here to document the steps I have tried. --&gt;
  
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>The current output of this code is nothing (literally).</p>
  
  <p><em>The desired output when the variable <code>value_to_lookup</code> is equal to "raw1" is:</em></p>
  
  <pre><code>Raw One
  </code></pre>
  
  <p><em>For further clarification, the desired output when the variable <code>value_to_lookup</code> is equal to "raw4" is:</em></p>
  
  <pre><code>Raw Four
  </code></pre>
  
  <p>The output of this bit of code will be stored in a variable and called later when needed.</p>
  
  <p>Thanks again!</p>