title: XSLT to set HTML bgcolor from XML text node
body: <p>I am trying to use XSLT to transform an XML to an HTML where the bgcolor attribute of a table cell is taken from the input XML for a specific column in the table. </p>
  
  <p>My XML:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;ROWSET&gt;
   &lt;ROW&gt;
    &lt;PROJECTS&gt;EPM Critical Patches – December 11, 2019&lt;/PROJECTS&gt;
    &lt;STATUS&gt;lime&lt;/STATUS&gt;
   &lt;/ROW&gt;
   &lt;ROW&gt;
    &lt;PROJECTS&gt;Archive Project&lt;/PROJECTS&gt;
    &lt;STATUS&gt;red&lt;/STATUS&gt;
   &lt;/ROW&gt;
   &lt;ROW&gt;
    &lt;PROJECTS&gt;12.1.9 ERP upgrade&lt;/PROJECTS&gt;
    &lt;STATUS&gt;lime&lt;/STATUS&gt;
   &lt;/ROW&gt;
  &lt;/ROWSET&gt;
  </code></pre>
  
  <p>My XSL:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; 
  &lt;xsl:template match="/"&gt;
  &lt;HTML&gt;
  &lt;BODY&gt;
      &lt;xsl:apply-templates/&gt;
  &lt;/BODY&gt;
  &lt;/HTML&gt;
  &lt;/xsl:template&gt;
   &lt;xsl:template match="/*"&gt;
  &lt;TABLE BORDER="0"&gt;
  &lt;TR&gt;&lt;TD&gt;&lt;CENTER&gt;&lt;font face="verdana" color="Blue" size="4"&gt;Go Live&lt;/font&gt;&lt;/CENTER&gt;&lt;/TD&gt;&lt;/TR&gt;
  &lt;TR&gt;
          &lt;xsl:for-each select="*[position() = 1]/*"&gt;
            &lt;TD style="font-family:verdana;font-size: 10px; " bgcolor="red"&gt;
                &lt;xsl:value-of select="local-name()"/&gt;
            &lt;/TD&gt;
          &lt;/xsl:for-each&gt;
  &lt;/TR&gt;
        &lt;xsl:apply-templates/&gt;
  &lt;/TABLE&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="/*/*"&gt;
  
  &lt;TR&gt;
      &lt;xsl:apply-templates/&gt;
  &lt;/TR&gt;
  
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="/*/*/*"&gt;
         &lt;xsl:choose&gt;
           &lt;xsl:when test="name() = 'STATUS'"&gt;
           &lt;TD style="font-family:verdana;font-size: 10px; " bgcolor ="{//STATUS}"&gt;  &lt;/TD&gt;
           &lt;/xsl:when&gt;
           &lt;xsl:otherwise&gt;
        &lt;TD style="font-family:verdana;font-size: 10px; "&gt; &lt;xsl:value-of select="."/&gt; &lt;/TD&gt;
           &lt;/xsl:otherwise&gt;
         &lt;/xsl:choose&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>The output I get:</p>
  
  <pre><code>&lt;HTML&gt;
     &lt;BODY&gt;
        &lt;TABLE BORDER="0"&gt;
           &lt;TR&gt;
              &lt;TD&gt;
                 &lt;CENTER&gt;
                    &lt;font face="verdana" color="Blue" size="4"&gt;Go Live&lt;/font&gt;
                 &lt;/CENTER&gt;
              &lt;/TD&gt;
           &lt;/TR&gt;
           &lt;TR&gt;
              &lt;TD style="font-family:verdana;font-size: 10px; " bgcolor="red"&gt;PROJECTS&lt;/TD&gt;
              &lt;TD style="font-family:verdana;font-size: 10px; " bgcolor="red"&gt;STATUS&lt;/TD&gt;
           &lt;/TR&gt;
           &lt;TR&gt;
              &lt;TD style="font-family:verdana;font-size: 10px; "&gt;EPM Critical Patches – December 11, 2019&lt;/TD&gt;
              &lt;TD style="font-family:verdana;font-size: 10px; " bgcolor="lime"/&gt;
           &lt;/TR&gt;
           &lt;TR&gt;
              &lt;TD style="font-family:verdana;font-size: 10px; "&gt;Archive Project&lt;/TD&gt;
              &lt;TD style="font-family:verdana;font-size: 10px; " bgcolor="lime"/&gt;
           &lt;/TR&gt;
           &lt;TR&gt;
              &lt;TD style="font-family:verdana;font-size: 10px; "&gt;12.1.9 ERP upgrade&lt;/TD&gt;
              &lt;TD style="font-family:verdana;font-size: 10px; " bgcolor="lime"/&gt;
           &lt;/TR&gt;
        &lt;/TABLE&gt;
     &lt;/BODY&gt;
  &lt;/HTML&gt;
  </code></pre>
  
  <p>The output I want: </p>
  
  <pre><code>&lt;HTML&gt;
     &lt;BODY&gt;
        &lt;TABLE BORDER="0"&gt;
           &lt;TR&gt;
              &lt;TD&gt;
                 &lt;CENTER&gt;
                    &lt;font face="verdana" color="Blue" size="4"&gt;Go Live&lt;/font&gt;
                 &lt;/CENTER&gt;
              &lt;/TD&gt;
           &lt;/TR&gt;
           &lt;TR&gt;
              &lt;TD style="font-family:verdana;font-size: 10px; " bgcolor="red"&gt;PROJECTS&lt;/TD&gt;
              &lt;TD style="font-family:verdana;font-size: 10px; " bgcolor="red"&gt;STATUS&lt;/TD&gt;
           &lt;/TR&gt;
           &lt;TR&gt;
              &lt;TD style="font-family:verdana;font-size: 10px; "&gt;EPM Critical Patches – December 11, 2019&lt;/TD&gt;
              &lt;TD style="font-family:verdana;font-size: 10px; " bgcolor="lime"/&gt;
           &lt;/TR&gt;
           &lt;TR&gt;
              &lt;TD style="font-family:verdana;font-size: 10px; "&gt;Archive Project&lt;/TD&gt;
              &lt;TD style="font-family:verdana;font-size: 10px; " bgcolor="red"/&gt;
           &lt;/TR&gt;
           &lt;TR&gt;
              &lt;TD style="font-family:verdana;font-size: 10px; "&gt;12.1.9 ERP upgrade&lt;/TD&gt;
              &lt;TD style="font-family:verdana;font-size: 10px; " bgcolor="lime"/&gt;
           &lt;/TR&gt;
        &lt;/TABLE&gt;
     &lt;/BODY&gt;
  &lt;/HTML&gt;
  </code></pre>
  
  <p>The bgcolor of the second cell in each row should have the value of the STATUS text node for that row in the input XML.  Instead, it repeats the value of the first rown throughout the rest. I also tried putting <code>&lt;xsl:value-of select="."/&gt;</code> in the bgcolor attribute but then it complained <em>"The value of attribute "bgcolor" associated with an element type "TD"</em> must not contain the '&lt;' character.".</p>
  
  <p>I also need a solution that is XSL 1.0 compliant as the vendor refuses to upgrade their parser in the technology stack. </p>