<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet
    xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
    version = "1.0">

 <xsl:template match="/">
  <xsl:choose>
   <xsl:when test="data/options/lang/@v = 'en'">
    <xsl:apply-templates select="data">
     <xsl:with-param name="trans" select="document('metaf-lang.xsl')//trans/en"/>
    </xsl:apply-templates>
   </xsl:when>
   <xsl:when test="data/options/lang/@v = 'es'">
    <xsl:apply-templates select="data">
     <xsl:with-param name="trans" select="document('metaf-lang.xsl')//trans/es"/>
    </xsl:apply-templates>
   </xsl:when>
   <xsl:when test="data/options/lang/@v = 'ru'">
    <xsl:apply-templates select="data">
     <xsl:with-param name="trans" select="document('metaf-lang.xsl')//trans/ru"/>
    </xsl:apply-templates>
   </xsl:when>
   <xsl:otherwise>
    <xsl:apply-templates select="data">
     <xsl:with-param name="trans" select="document('metaf-lang.xsl')//trans/de"/>
    </xsl:apply-templates>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>

 <xsl:template match="data">
  <xsl:param name="trans"/>
  <xsl:element name="html">
   <xsl:attribute name="lang">
    <xsl:value-of select="name($trans)"/>
   </xsl:attribute>
  <head>
  <title><xsl:value-of select="$trans/cgi[@o='title']"/></title>
  <meta name="robots" content="noindex,nofollow"/>
  <meta name="keywords"
      content="metaf2xml,METAR,TAF,SYNOP,XML,aviation,weather,report,forecast"/>
  </head>
  <body>
  <xsl:attribute name="lang">
   <xsl:value-of select="name($trans)"/>
  </xsl:attribute>
  <h2><xsl:value-of select="$trans/cgi[@o='title']"/></h2>
  <xsl:value-of select="$trans/cgi[@o='infosrc']"/>
  <xsl:text>: </xsl:text>
  <kbd>http://weather.noaa.gov/weather/coded.html</kbd>
  <p />
  <xsl:value-of select="$trans/cgi[@o='infofetch']"/>
  <p />
  <form method="post"
        action="metaf.pl"
        enctype="application/x-www-form-urlencoded">

<table border="0" cellspacing="0">
<tr>
<td nowrap="1"><xsl:value-of select="$trans/cgi[@o='language']"/></td>
<td>
 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">lang</xsl:attribute>
  <xsl:attribute name="value">de</xsl:attribute>
  <xsl:if test="not (options/lang/@v = 'en' or options/lang/@v = 'es' or options/lang/@v = 'ru')">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:text>Deutsch</xsl:text>
</td>
<td>
 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">lang</xsl:attribute>
  <xsl:attribute name="value">en</xsl:attribute>
  <xsl:if test="options/lang/@v = 'en'">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:text>English</xsl:text>
</td>
<td>
 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">lang</xsl:attribute>
  <xsl:attribute name="value">es</xsl:attribute>
  <xsl:if test="options/lang/@v = 'es'">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:text>Español</xsl:text>
</td>
<td>
 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">lang</xsl:attribute>
  <xsl:attribute name="value">ru</xsl:attribute>
  <xsl:if test="options/lang/@v = 'ru'">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:text>Русский</xsl:text>
</td>
</tr>

<tr>
<td nowrap="1"><xsl:value-of select="$trans/cgi[@o='format']"/></td>
<td>
 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">format</xsl:attribute>
  <xsl:attribute name="value">html</xsl:attribute>
  <xsl:if test="not (options/format/@v = 'text' or options/format/@v = 'xml')">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:value-of select="$trans/cgi[@o='format1']"/>
</td>
<td>
 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">format</xsl:attribute>
  <xsl:attribute name="value">text</xsl:attribute>
  <xsl:if test="options/format/@v = 'text'">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:value-of select="$trans/cgi[@o='format2']"/>
</td>
<td colspan="2">
 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">format</xsl:attribute>
  <xsl:attribute name="value">xml</xsl:attribute>
  <xsl:if test="options/format/@v = 'xml'">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:value-of select="$trans/cgi[@o='format3']"/>
</td>
</tr>

<tr>
<td nowrap="1"><xsl:value-of select="$trans/cgi[@o='mode']"/></td>
<td nowrap="1">
 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">mode</xsl:attribute>
  <xsl:attribute name="value">latest</xsl:attribute>
  <xsl:if test="not (options/mode/@v = 'summary')">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:value-of select="$trans/cgi[@o='mode1']"/>
</td>

<td colspan="2" nowrap="1">
 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">mode</xsl:attribute>
  <xsl:attribute name="value">summary</xsl:attribute>
  <xsl:if test="options/mode/@v = 'summary'">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:value-of select="$trans/cgi[@o='mode2']"/>
</td>
</tr>
</table>

<table border="0" cellspacing="0">
<tr><td colspan="2"><hr /></td></tr>
<tr>
<td><xsl:value-of select="$trans/cgi[@o='example']"/></td>
<td style="font-family: monospace;">
METAR YUDO 090600Z 00000KT CAVOK 22/15 Q1021 NOSIG
</td>
</tr>

<tr>
<td />
<td style="font-family: monospace;">
TAF YUDO 090600Z 090716 VRB03KT 8000 SKC PROB40 TEMPO 0708 0200 +TSRA FM0800 CAVOK
</td>
</tr>

<tr>
<td nowrap="1">
 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">type_metaf</xsl:attribute>
  <xsl:attribute name="value">metar</xsl:attribute>
  <xsl:if test="not (options/type_metaf/@v = 'taf')">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:value-of select="$trans/cgi[@o='type1']"/>
</td>

<td rowspan="3" valign="bottom">
 <xsl:element name="input">
  <xsl:attribute name="type">text</xsl:attribute>
  <xsl:attribute name="name">msg_metaf</xsl:attribute>
  <xsl:attribute name="size">80</xsl:attribute>
  <xsl:attribute name="maxlength">500</xsl:attribute>
  <xsl:attribute name="style">font-family: monospace;</xsl:attribute>
  <xsl:attribute name="value">
   <xsl:value-of select="options/msg_metaf/@v"/>
  </xsl:attribute>
 </xsl:element>
</td>
</tr>

<tr>
<td nowrap="1">
 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">type_metaf</xsl:attribute>
  <xsl:attribute name="value">taf</xsl:attribute>
  <xsl:if test="options/type_metaf/@v = 'taf'">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:value-of select="$trans/cgi[@o='type2']"/>
</td>
</tr>

<tr>
<td>
 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">type_metaf</xsl:attribute>
  <xsl:attribute name="value">icao</xsl:attribute>
  <xsl:if test="options/type_metaf/@v = 'icao'">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:value-of select="$trans/cgi[@o='type4']"/>
</td>
</tr>

<tr>
<td nowrap="1" align="right">
<xsl:value-of select="$trans/cgi[@o='source']"/>
</td>

<td>
 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">src_metaf</xsl:attribute>
  <xsl:attribute name="value">noaa</xsl:attribute>
  <xsl:if test="not (options/src_metaf/@v = 'adds' or options/src_metaf/@v = 'addsds') and not (options/src_metaf/@v = 'file')">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
  <xsl:if test="options/src_metaf/@v = 'file'">
   <xsl:attribute name="disabled">1</xsl:attribute>
   <xsl:attribute name="readonly">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:value-of select="$trans/cgi[@o='source1']"/>

 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">src_metaf</xsl:attribute>
  <xsl:attribute name="value">adds</xsl:attribute>
  <xsl:if test="options/src_metaf/@v = 'adds'">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
  <xsl:if test="options/src_metaf/@v = 'file'">
   <xsl:attribute name="disabled">1</xsl:attribute>
   <xsl:attribute name="readonly">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:value-of select="$trans/cgi[@o='source2']"/>

 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">src_metaf</xsl:attribute>
  <xsl:attribute name="value">addsds</xsl:attribute>
  <xsl:if test="options/src_metaf/@v = 'addsds'">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
  <xsl:if test="options/src_metaf/@v = 'file'">
   <xsl:attribute name="disabled">1</xsl:attribute>
   <xsl:attribute name="readonly">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:value-of select="$trans/cgi[@o='source3']"/>
</td>
</tr>

<tr><td colspan="2"><hr /></td></tr>

<tr>
<td><xsl:value-of select="$trans/cgi[@o='example']"/></td>
<td style="font-family: monospace;">
AAXX 09004 08495 11459 30714 10147 20136 30151 40159 58005 60001 70511 83500 92350
</td>
</tr>

<tr>
<td />
<td style="font-family: monospace;">
BBXX UIDS 18061 99613 70284 41698 61806 10000 40107 57020 70121 86//8 22271 00064
</td>
</tr>

<tr>
<td nowrap="1">
 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">type_synop</xsl:attribute>
  <xsl:attribute name="value">synop</xsl:attribute>
  <xsl:if test="options/type_synop/@v = 'synop'">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:value-of select="$trans/cgi[@o='type3']"/>
</td>

<td rowspan="2" valign="bottom">
 <xsl:element name="input">
  <xsl:attribute name="type">text</xsl:attribute>
  <xsl:attribute name="name">msg_synop</xsl:attribute>
  <xsl:attribute name="size">80</xsl:attribute>
  <xsl:attribute name="maxlength">500</xsl:attribute>
  <xsl:attribute name="style">font-family: monospace;</xsl:attribute>
  <xsl:attribute name="value">
   <xsl:value-of select="options/msg_synop/@v"/>
  </xsl:attribute>
 </xsl:element>
</td>
</tr>

<tr>
<td>
 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">type_synop</xsl:attribute>
  <xsl:attribute name="value">wmo</xsl:attribute>
  <xsl:if test="options/type_synop/@v = 'wmo'">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:value-of select="$trans/cgi[@o='type5']"/>
</td>
</tr>

<tr>
<td nowrap="1" align="right">
<xsl:value-of select="$trans/cgi[@o='source']"/>
</td>

<td>
 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">src_synop</xsl:attribute>
  <xsl:attribute name="value">nws_land</xsl:attribute>
  <xsl:if test="not (options/src_synop/@v = 'cod') and not (options/src_synop/@v = 'file')">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
  <xsl:if test="options/src_synop/@v = 'file'">
   <xsl:attribute name="disabled">1</xsl:attribute>
   <xsl:attribute name="readonly">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:value-of select="$trans/cgi[@o='source4']"/>

 <xsl:element name="input">
  <xsl:attribute name="type">radio</xsl:attribute>
  <xsl:attribute name="name">src_synop</xsl:attribute>
  <xsl:attribute name="value">cod</xsl:attribute>
  <xsl:if test="options/src_synop/@v = 'cod'">
   <xsl:attribute name="checked">1</xsl:attribute>
  </xsl:if>
  <xsl:if test="options/src_synop/@v = 'file'">
   <xsl:attribute name="disabled">1</xsl:attribute>
   <xsl:attribute name="readonly">1</xsl:attribute>
  </xsl:if>
 </xsl:element>
 <xsl:value-of select="$trans/cgi[@o='source5']"/>
</td>
</tr>

<tr><td colspan="2"><hr /></td></tr>

<tr>
<td colspan="2">
 <xsl:element name="input">
  <xsl:attribute name="type">submit</xsl:attribute>
  <xsl:attribute name="name">do_msg</xsl:attribute>
  <xsl:attribute name="value">
   <xsl:value-of select="$trans/cgi[@o='decode']"/>
  </xsl:attribute>
 </xsl:element>
</td>
</tr>

</table>

</form>
  <p />
  <xsl:if test="boolean(reports/metar) or boolean(reports/taf) or boolean(reports/synop)">
   <b><xsl:value-of select="$trans/cgi[@o='disclaimer']"/></b><p />
  </xsl:if>
  <xsl:apply-templates select="reports">
   <xsl:with-param name="trans" select="$trans"/>
  </xsl:apply-templates>
  <xsl:apply-templates select="versionList">
   <xsl:with-param name="version"> metaf-ui: $Id: metaf-ui.xsl,v 1.7 2007/09/11 12:57:25 metaf2xml Exp $ </xsl:with-param>
  </xsl:apply-templates>
  <p />copyright (c) 2006-2007 metaf2xml @ <a href="http://metaf2xml.sourceforge.net/"><img border="0" src="http://sflogo.sourceforge.net/sflogo.php?group_id=168043&amp;type=1" alt="SourceForge.net Logo"/></a>
  </body>
  </xsl:element>
 </xsl:template>

</xsl:stylesheet>
