<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="microsummary-generator.xsl" type="text/xsl"?>
<generator xmlns="http://www.mozilla.org/microsummaries/0.1" name="FlightStats Flight Status">

  <pages>
    <include>^http://www\.flightstats\.com/go/FlightStatus/flightStatusByFlight\.do</include>
  </pages>

  <update interval="15"/>

  <template>
    <transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <output method="text"/>
      <template match="/">

        <!-- airline code and flight number -->
        <!-- We get this from the header at the top of the page, which looks
           - like "@@ #### Flight Status" (where @@ is the airline code
           - and #### is the flight number).  We just grab the part before
           - the string " Flight Status". -->
        <value-of select="normalize-space(substring-before(string(id('subheaderLabel')/h1), ' Flight Status'))"/>

        <text>: </text>

        <!-- current status -->
        <!-- This changes position in the table depending on the status
           - of the flight, so we select the row with a "Status:" cell. -->
        <value-of select="normalize-space(string(id('resultsBlock')/table[1]/tbody/tr/td[1]/table/tbody/tr[normalize-space(td)='Status:']/td[3]))"/>
        <text>, </text>

        <!-- estimated or actual arrival -->
        <!-- For some reason this doesn't change position depending on the status
           - of the flight, at least not in my testing so far.  If we later find
           - that it does change, it might be hard to fix that the way we fixed
           - the status, since there are two "Actual" rows in the table, one for
           - departure and one for arrival.  Or perhaps we can just select
           - the second instance of a row with "Actual".  But we still have to
           - differentiate between "Actual" and "Estimated". -->
        <value-of select="normalize-space(string(id('resultsBlock')/table[1]/tbody/tr/td[1]/table/tbody/tr[21]/td[3]))"/>

      </template>

    </transform>
  </template>

</generator>

