469,330 Members | 1,330 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,330 developers. It's quick & easy.

Changing the background based on value in xml using xsl

I have a solarr grid tie system. the power data is dumped in xml. using xsl I want to change the color of the field based on the data going positive ( power from the grid ) or negative ( solar is pushing power to the grid )

I have been trying diffferent things and it just doesn't work. What am I missing ?

[html] <table border="3">
<tr bgcolor="#9acd32">
<th bgcolor="#ffff55" aligh="center" colspan="4">Current System Status</th>
<th bgcolor="#cc9966" aligh="center" colspan="4" border="3">Solar Energy System Status</th>
<tr bgcolor="#9acd32">
<th bgcolor="#ddea99" align="center">Neg=Solar Pos=REC</th>
<th bgcolor="#ddea99" align="center">Voltage</th>
<th bgcolor="#ddea99" align="center">Amps</th>
<th bgcolor="#ddea99" align="center">Consumption</th>
<xsl:if test="watts &lt; 0>
<td bgcolor="#00ff00"><xsl:value-of select="xmlpower/record/watts" /></td>
<xsl:if test="watts &gt; 0>
<td bgcolor="#ff0000"><xsl:value-of select="xmlpower/record/watts" /></td>
<td bgcolor="#ffff00"><xsl:value-of select="xmlpower/record/volts" /></td>
<td bgcolor="#ffff00"><xsl:value-of select="xmlpower/record/amps" /></td>
<td bgcolor="#ffff00"><xsl:value-of select="xmlpower/record/power" /></td>
Apr 12 '07 #1
3 2228
I forgot to mention exactt equal amounts work, just not GT or LT
Apr 12 '07 #2
839 Expert 512MB
Welcome to TheScripts TSDN....

Try this way:
[html]<xsl:if test="number(watts) &lt; 0">[/html]

Don't forget to close the quotation-marks after 0 (they are missing in your sample).
Apr 13 '07 #3
117 100+
in my opinion u should define a class and then make a method to change the background color, and then access that method through extention objects and then u can even change the color at run time and can use for large files, without even writing bgcolor='xxxx' properties every time.
Apr 18 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by Udo Marx | last post: by
11 posts views Thread by Konrad Den Ende | last post: by
7 posts views Thread by VB Programmer | last post: by
1 post views Thread by JC | last post: by
12 posts views Thread by GaryDean | last post: by
2 posts views Thread by Jason_SanDiego2006 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.