SharePoint Weather WebPart - Tomorrow, You're Always A Day Away

Last March I posted a tip on how to create your own weather web part for SharePoint that used Yahoo! as the data source. A couple of weeks ago reader "Noel" posted a comment that asked how to get the next day's forecast to show up. So I've modified the XSLT to do just that.
The problem is that there are two "forecast" nodes. One that represents today and the other for tomorrow. You need to reference the appropriate node by using a pattern match. In our case, the first child is the today's information and the second child is tomorrow's.

This is represented as...

Today  =  rss/channel/item/yweather:forecast[1]
Tomorrow  = rss/channel/item/yweather:forecast[2]

With that in mind, here is the modified XSLT.

<!--?xml version="1.0" encoding="ISO-8859-1"?-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
  <xsl:output method="html" indent="yes" />
  <xsl:template match="/">

    <style type="text/css">
      #tywpMain {position:relative; padding:0; margin:0; font-family: Helvetica, Arial; font-size: 10pt;}
      #tywpMain p {padding: 0; margin: 0;}
      #tywpMain table {width: 100%; border: collapse;}
      #tywpMain table thead th {font-family:"Verdana"; font-size:16pt; color:#fff; background-color:#888; padding:10px; text-align: left;}
      #tywpMain table thead th span {float: right;}
      #tywpMain table tbody th, #tywpMain table tbody td {padding: 0 4px; white-space: nowrap; text-align: center;}
      #tywpMain table tbody th {vertical-align: bottom; color: #888;}
      #tywpMain table tbody td {vertical-align: top; color: #000;}
      #tywpMain table tbody td.High {color: #800;}
      #tywpMain table tbody td.Low {color: #008;}
    </style>

    <xsl:variable name="Scale">
      <xsl:value-of select="rss/channel/yweather:units/@temperature" />
    </xsl:variable>
    <xsl:variable name="CurrentConditionCode" select="rss/channel/item/yweather:condition/@code" />
    <xsl:variable name="ForecastConditionCode" select="rss/channel/item/yweather:forecast[2]/@code" />

    <div id="tywpMain">
      <table>
        <thead>
          <tr>
            <th colspan="5">
              <xsl:value-of select="rss/channel/yweather:location/@city" />,
              <xsl:value-of select="rss/channel/yweather:location/@region" />
              <span>
                <xsl:value-of select="rss/channel/item/yweather:condition/@temp" />
                <xsl:text>°</xsl:text>
                <xsl:copy-of select="$Scale" />
              </span>
            </th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th>
              <xsl:value-of select="rss/channel/item/yweather:forecast[1]/@day" />
            </th>
            <td rowspan="2">
              <img src="http://us.i1.yimg.com/us.yimg.com/i/us/we/52/{$CurrentConditionCode}.gif" />
            </td>
            <th>Condition</th>
            <th>High</th>
            <th>Low</th>
          </tr>
          <tr>
            <td>
              <xsl:value-of select="rss/channel/item/yweather:forecast[1]/@date" />
            </td>
            <td>
              <xsl:value-of select="rss/channel/item/yweather:condition/@text" />
            </td>
            <td class="High">
              <xsl:value-of select="rss/channel/item/yweather:forecast[1]/@high" />
              <xsl:text>°</xsl:text>
              <xsl:copy-of select="$Scale" />
            </td>
            <td class="Low">
              <xsl:value-of select="rss/channel/item/yweather:forecast[1]/@low" />
              <xsl:text>°</xsl:text>
              <xsl:copy-of select="$Scale" />
            </td>
          </tr>
          <tr>
            <th>
              <xsl:value-of select="rss/channel/item/yweather:forecast[2]/@day" />
            </th>
            <td rowspan="2">
              <img src="http://us.i1.yimg.com/us.yimg.com/i/us/we/52/{$ForecastConditionCode}.gif" />
            </td>
            <th>Condition</th>
            <th>High</th>
            <th>Low</th>
          </tr>
          <tr>
            <td>
              <xsl:value-of select="rss/channel/item/yweather:forecast[2]/@date" />
            </td>
            <td>
              <xsl:value-of select="rss/channel/item/yweather:forecast[2]/@text" />
            </td>
            <td class="High">
              <xsl:value-of select="rss/channel/item/yweather:forecast[2]/@high" />
              <xsl:text>°</xsl:text>
              <xsl:copy-of select="$Scale" />
            </td>
            <td class="Low">
              <xsl:value-of select="rss/channel/item/yweather:forecast[2]/@low" />
              <xsl:text>°</xsl:text>
              <xsl:copy-of select="$Scale" />
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </xsl:template>
</xsl:stylesheet>