Subject: RE: [xsl] xsl:if statement with numeric From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx> Date: Sun, 28 Mar 2004 12:19:05 +0200 |
> -----Original Message----- > From: Tuan Luu [mailto:tuanluu@xxxxxx] > > somehow I did find a solution: > Hi, Well, to add a few pointers : > > > > <xsl:template match="monat"> > > <xsl:if test= "numeric(.) < 100.00"> This should be number() instead of numeric(), but this you already discovered.. > > <xsl:variable name="farbe">#00ff00</xsl:variable> > > </xsl:if> > > <td bgcolor="$farbe" align="right"> Then this here should become: <td bgcolor="{$farbe}" align="right"> Notice the curly braces {} to force the processor to interpret '$farbe' as a variable name, or more generally as an XPath expression. Somehow, I would consider putting a color-map somewhere in the source XML, the stylesheet or a separate XML, like: <colormap> <color min="0" color="#ff9600" /> <color min="98.70" color="#ff0000" /> <color min="100" color="#00ff00" /> </colormap> Then you could avoid all the xsl:choose / xsl:if logic by merely fetching the color value corresponding to the number value in question, like <xsl:template match="monat"> <td bgcolor="{/colormap/color[@min >= number(current())][1]/@color}" align="right"> ... So, fetch the color attribute from the first color node whose min value is greater than or equal to the current value. Hope this helps! Cheers, Andreas
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] xsl:if statement with num, Kenny Akridge | Thread | RE: [xsl] xsl:if statement with num, Andreas L. Delmelle |
RE: [xsl] xsl:if statement with num, Kenny Akridge | Date | RE: [xsl] xsl:if statement with num, Andreas L. Delmelle |
Month |