Advertising
- Untitled
- Sunday, October 22nd, 2006 at 8:25:23am MDT
- <!--
- This XSLT is used to translate an XML response from the weather.com
- XML API.
- You can format this file to your liking. Two things you may feel
- like doing:
- 1) Modify the layout of the fields or static text already defined
- 2) Add other fields from the XML response file that aren't referenced in this
- XSLT. You can grab a full list by just doing a:
- wget "http://xoap.weather.com/weather/local/$LOCID?cc=*&unit=$UNITS"
- (change $LOCID and $UNITS to suit your needs)
- -->
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
- <xsl:output method="text" disable-output-escaping="yes"/>
- <xsl:template match="weather">
- <xsl:apply-templates select="cc"/>
- <xsl:apply-templates select="dayf/day[@d='1']"/>
- </xsl:template>
- <xsl:template match="cc">
- <xsl:text>City: </xsl:text><xsl:value-of select="obst"/>
- <xsl:text>
- </xsl:text>
- <xsl:text>Temp: </xsl:text><xsl:value-of select="tmp"/><xsl:value-of select="/weather/head/ut"/>
- <xsl:if test="tmp != flik">
- <xsl:text> (FL: </xsl:text><xsl:value-of select="flik"/><xsl:value-of select="/weather/head/ut"/><xsl:text>)</xsl:text>
- </xsl:if>
- <xsl:text>
- Cond: </xsl:text><xsl:value-of select="t"/>
- <xsl:text>
- Wind: </xsl:text>
- <xsl:choose>
- <xsl:when test="wind/s = 'calm'"><xsl:text>0</xsl:text></xsl:when>
- <xsl:otherwise><xsl:value-of select="wind/s"/></xsl:otherwise>
- </xsl:choose>
- <xsl:value-of select="/weather/head/us"/><!--
- <xsl:choose>
- <xsl:when test="wind/s = 'calm'"><xsl:text>(0mph)</xsl:text></xsl:when>
- <xsl:otherwise><xsl:text> (</xsl:text><xsl:value-of select="round(wind/s * 0.6214)"/><xsl:text>mph)</xsl:text></xsl:otherwise>
- </xsl:choose> -->
- <xsl:text> (</xsl:text><xsl:value-of select="wind/t"/>
- <xsl:text>)</xsl:text>
- </xsl:template>
- <xsl:template match="dayf/day[@d='1']">
- <xsl:text>
- Tomorrow: </xsl:text><xsl:value-of select="low"/><xsl:value-of select="/weather/head/ut"/>
- <xsl:text> to </xsl:text><xsl:value-of select="hi"/><xsl:value-of select="/weather/head/ut"/>
- <xsl:text>,
- </xsl:text><xsl:value-of select="part[@p='d']/t"/>
- <xsl:text></xsl:text><xsl:value-of select="/weather/swa/a/t"/>
- <!-- <xsl:text>
- </xsl:text> -->
- </xsl:template>
- </xsl:stylesheet>
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.