<?xml version="1.0" encoding="UTF-8"?>
<grammar ns="urn:oasis:names:tc:emergency:cap:1.2" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <start>
    <a:documentation>STRUCTURE OF TYPHOON ADVISORY IN CAP (COMMON ALERTING PROTOCOL) FORMAT
RSMC TOKYO - TYPHOON CENTER</a:documentation>
    <ref name="cap_rsmctk_typhoon"/>
  </start>
  <define name="cap_rsmctk_typhoon">
    <element name="alert">
      <element name="identifier">
        <a:documentation>Identifies a CAP message, in UUID format.</a:documentation>
        <data type="NMTOKEN">
          <param name="pattern">[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}</param>
        </data>
      </element>
      <element name="sender">
        <a:documentation>Currently fixed, using email address.</a:documentation>
        <data type="token">
          <param name="pattern">[\-\w]+@[.\w]+</param>
        </data>
      </element>
      <element name="sent">
        <a:documentation>Time of dissemination of the message.</a:documentation>
        <data type="dateTime">
          <param name="pattern">[\d\-]+T[\d:]+\+00:00</param>
        </data>
      </element>
      <element name="status">
        <a:documentation>Operational status,
currently chosen from three options.</a:documentation>
        <choice>
          <value>Actual</value>
          <value>Exercise</value>
          <value>Test</value>
        </choice>
      </element>
      <element name="msgType">
        <a:documentation>Currently fixed.</a:documentation>
        <value>Alert</value>
      </element>
      <element name="scope">
        <a:documentation>Currently fixed.</a:documentation>
        <value>Public</value>
      </element>
      <element name="code">
        <a:documentation>! element "restriction" not used</a:documentation>
        <a:documentation>Currently fixed: profile to CAP format.</a:documentation>
        <value>CAP-RSMCTK</value>
      </element>
      <oneOrMore>
        <ref name="info">
          <a:documentation>! element "note" not used</a:documentation>
          <a:documentation>! element "references" not used</a:documentation>
          <a:documentation>! element "incidents" not used</a:documentation>
          <a:documentation>An "info" element is created for each time level
(analysis or forecast hour).</a:documentation>
        </ref>
      </oneOrMore>
    </element>
  </define>
  <define name="info">
    <element name="info">
      <element name="language">
        <a:documentation>indicating English</a:documentation>
        <value>en-US</value>
      </element>
      <element name="category">
        <a:documentation>Word "Met" for Meteorology.</a:documentation>
        <value>Met</value>
      </element>
      <element name="event">
        <a:documentation>Type of event,
actually machine-readable type of "info" block.</a:documentation>
        <choice>
          <value>TROPICAL CYCLONE ADVISORY/ANALYSIS</value>
          <value>TROPICAL CYCLONE ADVISORY/FORECAST</value>
        </choice>
      </element>
      <element name="urgency">
        <a:documentation>! element "responseType" not used</a:documentation>
        <a:documentation>Currently fixed.</a:documentation>
        <!--
          Right now JMA is not in a position
          to prioritize or to de-priotize a part of Typhoon advisories.
        -->
        <value>Unknown</value>
      </element>
      <element name="severity">
        <a:documentation>Curently fixed.</a:documentation>
        <!--
          Right now JMA is not in a position
          to prioritize or to de-priotize a part of Typhoon advisories.
        -->
        <value>Unknown</value>
      </element>
      <element name="certainty">
        <a:documentation>Word "Observed" for present position.
"Likely (50% or more)" for forecast position,
having circle of 70% likeliness in mind.</a:documentation>
        <choice>
          <value>Observed</value>
          <value>Likely</value>
        </choice>
      </element>
      <element name="eventCode">
        <a:documentation>- element eventCode[1]
Machine-readable type of "info" block.</a:documentation>
        <element name="valueName">
          <value>EventType</value>
        </element>
        <element name="value">
          <choice>
            <value>TC_Analysis</value>
            <value>TC_Forecast24</value>
            <value>TC_Forecast45</value>
            <value>TC_Forecast48</value>
            <value>TC_Forecast69</value>
            <value>TC_Forecast72</value>
            <value>TC_Forecast96</value>
            <value>TC_Forecast120</value>
          </choice>
        </element>
      </element>
      <element name="effective">
        <a:documentation>Time at which the message take effect.</a:documentation>
        <data type="dateTime">
          <param name="pattern">[\d\-]+T[\d:]+\+00:00</param>
        </data>
      </element>
      <element name="onset">
        <a:documentation>Time for which this "info" block is describing.</a:documentation>
        <data type="dateTime">
          <param name="pattern">[\d\-]+T[\d:]+\+00:00</param>
        </data>
      </element>
      <element name="expires">
        <a:documentation>Time at which the message is to be superseded by newer message.</a:documentation>
        <data type="dateTime">
          <param name="pattern">[\d\-]+T[\d:]+\+00:00</param>
        </data>
      </element>
      <element name="senderName">
        <a:documentation>Currently fixed: human-readable sender.</a:documentation>
        <value>RSMC Tokyo - Typhoon Center</value>
      </element>
      <element name="headline">
        <a:documentation>Human-readable headline, preferably shorter than 160 letters.</a:documentation>
        <data type="token">
          <param name="maxLength">160</param>
        </data>
      </element>
      <element name="description">
        <a:documentation>Human-readable description.</a:documentation>
        <text/>
      </element>
      <element name="web">
        <a:documentation>! element "instruction" not used.</a:documentation>
        <a:documentation>Link to web resource.
Currently fixed.</a:documentation>
        <value>http://www.jma.go.jp/en/typh/index.html</value>
      </element>
      <element name="parameter">
        <a:documentation>! element "contact" not used.</a:documentation>
        <a:documentation>- element parameter[1]
RSMC Tokyo's internal identification number of the tropical cyclone.
Note: if you are looking for the number associated with name,
use parameter[@valueName = 'TC_CycloneID'] instead.</a:documentation>
        <element name="valueName">
          <value>TC_Number</value>
        </element>
        <element name="value">
          <data type="positiveInteger">
            <param name="maxInclusive">9999</param>
          </data>
        </element>
      </element>
      <oneOrMore>
        <element name="parameter">
          <a:documentation>parameters
See parameter.xsl for contents</a:documentation>
          <element name="valueName">
            <data type="NMTOKEN"/>
          </element>
          <element name="value">
            <text/>
          </element>
        </element>
      </oneOrMore>
      <choice>
        <a:documentation>! element "resource" not used.</a:documentation>
        <a:documentation>area description</a:documentation>
        <ref name="pos"/>
        <ref name="probability_circle"/>
      </choice>
    </element>
  </define>
  <define name="pos">
    <element name="area">
      <a:documentation>- element area[1]
estimated position of the tropical storm
(shown as point regardless its confidence)</a:documentation>
      <element name="areaDesc">
        <text/>
      </element>
      <element name="circle">
        <data type="string">
          <param name="pattern">-?\d+\.\d,-?\d+\.\d 0</param>
        </data>
      </element>
    </element>
    <zeroOrMore>
      <element name="area">
        <a:documentation>- element area[position()&gt;1]
storm warning (if any) and gale warning
(shown as circles, which may be biased from the centre)</a:documentation>
        <element name="areaDesc">
          <empty/>
        </element>
        <element name="circle">
          <data type="string">
            <param name="pattern">-?\d+\.\d,-?\d+\.\d \d+</param>
          </data>
        </element>
      </element>
    </zeroOrMore>
  </define>
  <define name="probability_circle">
    <element name="area">
      <a:documentation>- element area[1]
forecast position of the tropical storm
(shown as circle of 70% probability)</a:documentation>
      <element name="areaDesc">
        <text/>
      </element>
      <element name="circle">
        <data type="string">
          <param name="pattern">-?\d+\.\d,-?\d+\.\d \d+</param>
        </data>
      </element>
    </element>
  </define>
</grammar>
