#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2008
    Posts
    71
    Rep Power
    7

    XSL Concatenate 3 values - having trouble!


    QUESTION: The attributes for height and width appear in the rendered HTML, however the specified Background-color is not showing up. Any ideas why this might be?

    EXAMPLE OF XML:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <channel>
        <title>Colour Guide</title>
        <link></link>
        <description>hi</description>
        <lastBuildDate>Mon, 13 Dec 2010 12:14:59 GMT</lastBuildDate>
        <image>
            <title>hello</title>
            <url>pages/pagethirtytwo/subsection</url>
            <link></link>
        </image>
        <item>
            <title>Player 12</title>
            <link></link>
            <ref id="80-2563">
                <shortdesc>Midfield, Defense</shortdesc>
                <longdesc>Midfield Defensive player.</longdesc>
                <L>87.04</L>
                <A>-4.3</A>
                <B>84.39</B>
                <R>239</R>
                <G>216</G>
                <B2>33</B2>
            </ref>
        </item>
    </channel>

    XSLT code that is giving me trouble:
    Code:
    <xsl:for-each select="ref"><td><xsl:attribute name="style"><![CDATA[height:12px;width:12px;background-color:(]]><xsl:value-of select = "concat(R,',',G,',',B2)" /><![CDATA[)]]></xsl:attribute></td></xsl:for-each>
    Full code:
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" encoding="utf-8"/>
    	<xsl:template match="/">
    	  <xsl:apply-templates select="channel" />
    	  <xsl:call-template name="items"/>
    	</xsl:template>
    	<xsl:template match="channel">
    		<div class="ChannelTitle">
    		  <h1><xsl:element name="a"><xsl:attribute name="title"><xsl:value-of disable-output-escaping="yes" select="title" /></xsl:attribute><xsl:attribute name="href"><xsl:value-of disable-output-escaping="yes" select="link" /></xsl:attribute></xsl:element></h1>
    		  <h3><xsl:value-of disable-output-escaping="yes" select="description" /></h3>
    		</div>
    	</xsl:template>
    	<xsl:template name="items">
    		<xsl:for-each select="channel/item">
    		  <div class="Article">
    		    <h3 id="ArticleTitle"><xsl:element name="a"><xsl:attribute name="title"><xsl:value-of disable-output-escaping="yes" select="title" /></xsl:attribute><xsl:attribute name="href"><xsl:value-of disable-output-escaping="yes" select="link" /></xsl:attribute></xsl:element></h3>
    		    <p id="ArticleDescription">
    		    	<table cellspacing="0" cellpadding="0" border="0">
    					<tr>
    						<xsl:for-each select="ref"><td><xsl:attribute name="style"><![CDATA[height:12px;width:12px;background-color:(]]><xsl:value-of select = "concat(R,',',G,',',B2)" /><![CDATA[)]]></xsl:attribute> <xsl:value-of select = "concat(R,',',G,',',B2)" /> </td></xsl:for-each>
    					</tr>
    				</table>
    			</p>
    		  </div>
    	  	</xsl:for-each>
    	</xsl:template>
    </xsl:stylesheet>

    Thanks,
    Seth
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,247
    Rep Power
    9400
    In case you haven't figured it out,

    It's quite simple, actually.
    Code:
    <![CDATA[height:12px;width:12px;background-color:(]]><xsl:value-of select = "concat(R,',',G,',',B2)" /><![CDATA[)]]>
    Say R=239, G=216, and B2=33: the output would be
    Code:
    height:12px;width:12px;background-color:(239,216,33)
    See anything wrong? Need a quick reminder about how background-color works?

IMN logo majestic logo threadwatch logo seochat tools logo