Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

Untitled
Sunday, October 22nd, 2006 at 8:25:23am MDT 

  1. <!--
  2.  
  3.  This XSLT is used to translate an XML response from the weather.com
  4.  XML API.
  5.  
  6.  You can format this file to your liking. Two things you may feel
  7.  like doing:
  8.  
  9.         1) Modify the layout of the fields or static text already defined
  10.         2) Add other fields from the XML response file that aren't referenced in this
  11.            XSLT. You can grab a full list by just doing a:
  12.            wget "http://xoap.weather.com/weather/local/$LOCID?cc=*&unit=$UNITS"
  13.            (change $LOCID and $UNITS to suit your needs)
  14. -->
  15.  
  16. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
  17.         <xsl:output method="text" disable-output-escaping="yes"/>
  18.         <xsl:template match="weather">
  19.                 <xsl:apply-templates select="cc"/>
  20.                 <xsl:apply-templates select="dayf/day[@d='1']"/>
  21.         </xsl:template>
  22.  
  23.        
  24.         <xsl:template match="cc">
  25.                 <xsl:text>City: </xsl:text><xsl:value-of select="obst"/> 
  26. <xsl:text>
  27. </xsl:text>
  28. <xsl:text>Temp: </xsl:text><xsl:value-of select="tmp"/><xsl:value-of select="/weather/head/ut"/>
  29. <xsl:if test="tmp != flik">
  30. <xsl:text> (FL: </xsl:text><xsl:value-of select="flik"/><xsl:value-of select="/weather/head/ut"/><xsl:text>)</xsl:text>
  31. </xsl:if>
  32. <xsl:text>
  33. Cond: </xsl:text><xsl:value-of select="t"/>
  34. <xsl:text>
  35. Wind: </xsl:text>
  36. <xsl:choose>
  37.         <xsl:when test="wind/s = 'calm'"><xsl:text>0</xsl:text></xsl:when>
  38.         <xsl:otherwise><xsl:value-of select="wind/s"/></xsl:otherwise>
  39. </xsl:choose>
  40. <xsl:value-of select="/weather/head/us"/><!--
  41. <xsl:choose>
  42.         <xsl:when test="wind/s = 'calm'"><xsl:text>(0mph)</xsl:text></xsl:when>
  43.         <xsl:otherwise><xsl:text> (</xsl:text><xsl:value-of select="round(wind/s * 0.6214)"/><xsl:text>mph)</xsl:text></xsl:otherwise>
  44. </xsl:choose> -->
  45. <xsl:text> (</xsl:text><xsl:value-of select="wind/t"/>
  46. <xsl:text>)</xsl:text>
  47.         </xsl:template>
  48.  
  49.         <xsl:template match="dayf/day[@d='1']">
  50. <xsl:text>
  51. Tomorrow: </xsl:text><xsl:value-of select="low"/><xsl:value-of select="/weather/head/ut"/>
  52. <xsl:text> to </xsl:text><xsl:value-of select="hi"/><xsl:value-of select="/weather/head/ut"/>
  53. <xsl:text>,
  54. </xsl:text><xsl:value-of select="part[@p='d']/t"/>
  55. <xsl:text></xsl:text><xsl:value-of select="/weather/swa/a/t"/>
  56.   <!-- <xsl:text>
  57.   </xsl:text> -->
  58.         </xsl:template>
  59. </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.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



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.

worth-right
fantasy-obligation