Q:

Errors with outputting XML values into CSS with XSL

Trying to get all the <colors> values from example.xml to output them into example.xsl but am running into issues when outputting the results onto my website.
Below is an abstraction of the files that I am using...
example.xml
<plant id="1">
    <colors>
       <green>#00FF00</green>
       <red>#FF0000</red>
       <blue>#0000FF</blue>
    </colors>
</plant>

example.xsl
<xsl:for-each select="colors/*">
    <span class="colors" style="background-color:{colors/*};"></span>
</xsl:for-each>

I am getting an error with style="background-color:{colors/*};" between the two { } brackets .
Therefore, what can I do to output the color values of all the elements under <colors> into CSS?

A:

You have already selected the colors/* elements in the for-each loop, therefore the context element inside the loop is just ..
Try:
<xsl:for-each select="colors/*">
    <span class="colors" style="background-color:{.};"></span>
</xsl:for-each>

Or to be more precise:
<xsl:for-each select="colors/*">
    <span class="colors" style="background-color:{./text()};"></span>
</xsl:for-each>

