title: Use XSL to parse XML "color" attribute to fill a table cell
body: <p>I'm learning XML and I'm running into the following problem: I have an attribute in my XML file which can have a color as content (e.g. <code>&lt;color&gt;red&lt;/color&gt;</code>), but I don't know how to use it.</p>
  
  <p>My XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;cars&gt;
      &lt;car year="2002" manufacturer="Jet" model="Sardine Can 1.6L"&gt;
          &lt;meter&gt;95664&lt;/meter&gt;
          &lt;color&gt;silver&lt;/color&gt;
          &lt;price&gt;099900&lt;/price&gt;
          &lt;dealersecurity buyback="no"/&gt;
      &lt;/car&gt;
      &lt;car year="2004" manufacturer="Jet" model="Sardine Can 2.0"&gt;
          &lt;meter&gt;81283&lt;/meter&gt;
          &lt;color&gt;red&lt;/color&gt;
          &lt;price&gt;129900&lt;/price&gt;
          &lt;dealersecurity buyback="no"/&gt;
      &lt;/car&gt;
      &lt;car year="2007" manufacturer="Jet" model="Sardine Can 2.0"&gt;
          &lt;meter&gt;49741&lt;/meter&gt;
          &lt;color&gt;black&lt;/color&gt;
          &lt;price&gt;169999&lt;/price&gt;
          &lt;dealersecurity buyback="yes"/&gt;
      &lt;/car&gt;
  &lt;/cars&gt;
  </code></pre>
  
  <p>My XSL:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
      xmlns="http://www.w3.org/1999/xhtml"
      version="1.0"&gt;
    &lt;xsl:output method="xml"/&gt;
  
    &lt;xsl:template match="/cars"&gt;
      &lt;html&gt;
        &lt;head&gt;&lt;title&gt;Second Hand Sardine Cans&lt;/title&gt;  
          &lt;link rel="stylesheet" type="text/css" href="style.css"/&gt;&lt;/head&gt;
        &lt;body&gt;
        &lt;h1&gt;Second Hand Sardine Cans&lt;/h1&gt;
        &lt;table border="1"&gt;&lt;th&gt;Make&lt;/th&gt;&lt;th&gt;Model&lt;/th&gt;&lt;th&gt;Year&lt;/th&gt;&lt;th&gt;KMs&lt;/th&gt;&lt;th&gt;Color&lt;/th&gt;&lt;th&gt;Price&lt;/th&gt;&lt;th&gt;Warranty&lt;/th&gt;&lt;xsl:apply-templates/&gt;&lt;/table&gt;
        &lt;/body&gt;
      &lt;/html&gt;
    &lt;/xsl:template&gt;
  
   &lt;xsl:template match="cars/car"&gt;
    &lt;tr&gt;&lt;xsl:for-each select="cars/car"/&gt;
    &lt;td&gt;&lt;xsl:value-of select="@manufacturer" /&gt;&lt;/td&gt;
    &lt;td&gt;&lt;xsl:value-of select="@model" /&gt;&lt;/td&gt;
    &lt;td&gt;&lt;xsl:value-of select="@year" /&gt;&lt;/td&gt;
    &lt;td&gt;&lt;xsl:value-of select="meter" /&gt;&lt;/td&gt;
          &lt;xsl:apply-templates/&gt;&lt;/tr&gt;
    &lt;/xsl:template&gt;
  
    &lt;xsl:template match="meter"/&gt;
  
    &lt;xsl:template match="color"&gt;
    &lt;td&gt;&lt;xsl:apply-templates /&gt;&lt;/td&gt;
    &lt;/xsl:template&gt;
  
    &lt;xsl:template match="price"&gt;
    &lt;td&gt;&lt;xsl:apply-templates /&gt;&lt;/td&gt;
    &lt;/xsl:template&gt;
  
    &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>What I have until now:<br />
  <img src="https://i.stack.imgur.com/ApAM2.png" alt="Result until now"></p>
  
  <p>But instead of it saying "Red" or "Black", I want that cell to fill with that exact color.</p>
  
  <p>Thanks!</p>
  
  <p>Edit: I fixed it with the help of Dimitre's answer. I added <code>&lt;td bgcolor="{color}"&gt;&lt;xsl:value-of select="color" /&gt;&lt;/td&gt;</code> below <code>&lt;td&gt;&lt;xsl:value-of select="meter" /&gt;&lt;/td&gt;</code></p>