View Single Post
  #1 (permalink)  
Old August 8th, 2005, 11:11 AM
kwilliams kwilliams is offline
Banned
Points: 1,561, Level: 16
Points: 1,561, Level: 16 Points: 1,561, Level: 16 Points: 1,561, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2005
Location: , , .
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default <xsl:if test="" Question

I'm going to be using a few RSS/XML feeds for our new site, including the National Weather Services "Current Conditions" feed at http://www.nws.noaa.gov/data/current_obs/KLWC.xml. I'm also going to use their built-in icons with this feed, which can be found at http://www.nws.noaa.gov/data/current_obs/weather.php.

Everything's going very well so far, but I have a question concerning the xsl:if method. Is there an easier way to use multiple filters in the test function of this method? Right now, I'm using this:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="UTF-8" indent="yes"/> <xsl:variable name="var_weather" select="document('http://www.nws.noaa.gov/data/current_obs/KLWC.xml')" /> <xsl:param name="par_currentweather" select="$var_weather/current_observation/weather" /> <xsl:template match="/">  <xsl:if test="$par_currentweather = 'Mostly Cloudy' or $par_currentweather = 'Mostly Cloudy with Haze'"> <a href="http://www.crh.noaa.gov/ifps/MapClick.php?CityName=Lawrence&state=KS&site=TOP" target="_blank"> <img title="{$par_currentweather}" height="58" alt="{$par_currentweather}" src="http://weather.gov/weather/images/fcicons/bkn.jpg" width="55" /> </a> </xsl:if>  <xsl:if test="$par_currentweather = 'Fair' or $par_currentweather = 'Clear'"> <a href="http://www.crh.noaa.gov/ifps/MapClick.php?CityName=Lawrence&state=KS&site=TOP" target="_blank"> <img title="{$par_currentweather}" height="58" alt="{$par_currentweather}" src="http://weather.gov/weather/images/fcicons/skc.jpg" width="55" /> </a> </xsl:if> </xsl:template> </xsl:stylesheet>
...but because some of the "current weather" filters are as long as this one:

Thunderstorm | Light Thunderstorm Rain | Heavy Thunderstorm Rain | Thunderstorm Rain Fog/Mist | Light Thunderstorm Rain Fog/Mist | Heavy Thunderstorm Rain Fog/Mist | Thunderstorm Showers in Vicinity | | Light Thunderstorm Rain Haze | Heavy Thunderstorm Rain Haze | Thunderstorm Fog | Light Thunderstorm Rain Fog | Heavy Thunderstorm Rain Fog | Thunderstorm Light Rain | Thunderstorm Heavy Rain | Thunderstorm Rain Fog/Mist | Thunderstorm Light Rain Fog/Mist | Thunderstorm Heavy Rain Fog/Mist | Thunderstorm in Vicinity Fog/Mist | Thunderstorm Showers in Vicinity | Thunderstorm in Vicinity | Thunderstorm in Vicinity Haze | Thunderstorm Haze in Vicinity | Thunderstorm Light Rain Haze | Thunderstorm Heavy Rain Haze | Thunderstorm Fog | Thunderstorm Light Rain Fog | Thunderstorm Heavy Rain Fog | Thunderstorm Hail | Light Thunderstorm Rain Hail | Heavy Thunderstorm Rain Hail | Thunderstorm Rain Hail Fog/Mist | Light Thunderstorm Rain Hail Fog/Mist | Heavy Thunderstorm Rain Hail Fog/Mist | Thunderstorm Showers in Vicinity Hail | | Light Thunderstorm Rain Hail Haze | Heavy Thunderstorm Rain Hail Haze | Thunderstorm Hail Fog | Light Thunderstorm Rain Hail Fog | Heavy Thunderstorm Rain Hail Fog | Thunderstorm Light Rain Hail | Thunderstorm Heavy Rain Hail | Thunderstorm Rain Hail Fog/Mist | Thunderstorm Light Rain Hail Fog/Mist | Thunderstorm Heavy Rain Hail Fog/Mist | Thunderstorm in Vicinity Hail Fog/Mist | Thunderstorm Showers in Vicinity Hail | Thunderstorm in Vicinity Hail | Thunderstorm in Vicinity Hail Haze | Thunderstorm Haze in Vicinity Hail | Thunderstorm Light Rain Hail Haze | Thunderstorm Heavy Rain Hail Haze | Thunderstorm Hail Fog | Thunderstorm Light Rain Hail Fog | Thunderstorm Heavy Rain Hail Fog | Thunderstorm Small Hail/Snow Pellets | Thunderstorm Rain Small Hail/Snow Pellets | Light Thunderstorm Rain Small Hail/Snow Pellets | Heavy Thunderstorm Rain Small Hail/Snow Pellets

...I'd obviously like to find a simpler way of doing this. If anyone knows of such a way, I'd LOVE to know it. Thanks for any help.

KWilliams
Reply With Quote