<?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"/>

<!-- NaturalViewObX.xsl                                                    -->
<!-- Jim Calkins, MDL                                                      -->
<!--                                                                       -->
<!-- This simple Stylesheet will present the contents of the Observations  -->
<!-- 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 METAR ID, City Name, and the observations -->
   <xsl:text>                          HI   LO   PRECIP</xsl:text>
   <xsl:text>&#10;</xsl:text>
   <xsl:for-each select="data/parameters">
      <xsl:variable name="loc" select="@applicable-location"/>
      <xsl:value-of select="$loc"/>
      <xsl:text>&#32;</xsl:text>
      <xsl:variable name="cityname" select="$cities[location-key=$loc]/city"/>
      <xsl:value-of select="substring(concat(string($cityname), '                    '), 1, 20)" />
      <xsl:if test="string-length(temperature[@type='maximum']/value) &lt; 3"><xsl:text>&#32;</xsl:text></xsl:if>
      <xsl:if test="string-length(temperature[@type='maximum']/value) &lt; 2"><xsl:text>&#32;</xsl:text></xsl:if>
      <xsl:value-of select="temperature[@type='maximum']/value"/>
      <xsl:text>F</xsl:text>
      <xsl:text>&#32;</xsl:text>
      <xsl:if test="string-length(temperature[@type='minimum']/value) &lt; 3"><xsl:text>&#32;</xsl:text></xsl:if>
      <xsl:if test="string-length(temperature[@type='minimum']/value) &lt; 2"><xsl:text>&#32;</xsl:text></xsl:if>
      <xsl:value-of select="temperature[@type='minimum']/value"/>
      <xsl:text>F</xsl:text>
      <xsl:text>&#32;</xsl:text>
      <xsl:if test="string-length(precipitation/value) &lt; 5"><xsl:text>&#32;</xsl:text></xsl:if>
      <xsl:value-of select="precipitation/value"/>
      <xsl:text>"</xsl:text>
      <xsl:text>&#10;</xsl:text>
   </xsl:for-each>
   <xsl:text>&#10;</xsl:text>

</xsl:template>

</xsl:stylesheet>