<xsl:if test="" Question

webmasterbeta

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

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:
<?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="/">

<!-- For current conditions: Mostly Cloudy | Mostly Cloudy with Haze | Mostly Cloudy and Breezy -->
<xsl:if test="$par_currentweather = 'Mostly Cloudy' or $par_currentweather = 'Mostly Cloudy with Haze'">
<a href=http://www.webdeveloper.com/forum/archive/index.php/"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>
<!-- For current conditions: Fair | Clear | Fair with Haze | Clear with Haze | Fair and Breezy | Clear and Breezy -->
<xsl:if test="$par_currentweather ='Fair' or $par_currentweather = 'Clear'">
<a href=http://www.webdeveloper.com/forum/archive/index.php/"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.
 
Back
Top