<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>

<!-- NaturalViewTEX.xsl                                                            -->
<!-- Jim Calkins, MDL                                                              -->
<!--                                                                               -->
<!-- This simple Stylesheet will present the contents of the Temperature Extremes  -->
<!-- in XML (TEX) in a simple format that is easy to view by the user.             -->

<xsl:template match="dwml">
<!-- Create some variables for later use. -->
   <xsl:variable name="cities" select="data/location" />
<!-- Output descriptive header information -->
   <xsl:value-of select="head/product/title" />
   <xsl:text>&#10;</xsl:text>
<!-- Format the date -->
   <xsl:value-of select="head/product/creation-date" />
   <xsl:text>&#10;&#10;</xsl:text>
<!-- Output the High Temperature's METAR ID, City Name, and the temperature value -->
   <xsl:text>National High Temperature</xsl:text>
   <xsl:text>&#10;</xsl:text>
   <xsl:for-each select="data/parameters">
      <xsl:if test="temperature[@type='maximum']">
         <xsl:variable name="maxloc" select="@applicable-location"/>
         <xsl:value-of select="$maxloc"/>
         <xsl:text>&#32;</xsl:text>
         <xsl:variable name="maxcityname" select="$cities[location-key=$maxloc]/city"/>
         <xsl:value-of select="$maxcityname" />
         <xsl:text>&#32;&#32;&#32;&#32;&#32;&#32;</xsl:text>
         <xsl:value-of select="temperature/value"/>
         <xsl:text>F</xsl:text>
         <xsl:text>&#10;</xsl:text>
      </xsl:if>
   </xsl:for-each>
   <xsl:text>&#10;</xsl:text>
<!-- Output the Low Temperature's METAR ID, City Name, and the temperature value -->
   <xsl:text>National Low  Temperature</xsl:text>
   <xsl:text>&#10;</xsl:text>
   <xsl:for-each select="data/parameters">
      <xsl:if test="temperature[@type='minimum']">
         <xsl:variable name="minloc" select="@applicable-location"/>
         <xsl:value-of select="$minloc"/>
         <xsl:text>&#32;</xsl:text>
         <xsl:variable name="mincityname" select="$cities[location-key=$minloc]/city"/>
         <xsl:value-of select="$mincityname" />
         <xsl:text>&#32;&#32;&#32;&#32;&#32;&#32;</xsl:text>
         <xsl:value-of select="temperature/value"/>
         <xsl:text>F</xsl:text>
         <xsl:text>&#10;</xsl:text>
      </xsl:if>
   </xsl:for-each>
   <xsl:text>&#10;</xsl:text>
</xsl:template>

</xsl:stylesheet>