<generator name='Alexa Traffic Ranking' xmlns='http://www.mozilla.org/microsummaries/0.1'>
  <template>
    <transform version='1.0' xmlns='http://www.w3.org/1999/XSL/Transform'>
      <output method='text'/>
      <template match='/'>
        <!-- The site being ranked. -->
        <value-of select='id(&apos;content&apos;)/table[1]/tbody/tr/td[1]/table/tbody/tr/td[1]/span[1]'/>
        <text>: </text>

        <!-- The daily traffic ranking. -->
        <!-- To get this, we first find the h2 header that reads
           - "Traffic Rank for [site]", then we walk the tree to its succeeding
           - table, which contains the rank in a specific cell.
           -->
        <variable name='daily' select='normalize-space(//h2[contains(., &apos;Traffic Rank for&apos;)]/following-sibling::table[position()=1]/tbody/tr[2]/td[1])'/>

        <!-- Only the top 100k sites have a daily ranking, so we show
           - the weekly ranking for the rest.
           -->
        <choose>
          <when test='$daily = &apos;N/A*&apos;'>
            <!-- The weekly traffic ranking. -->
            <value-of select='normalize-space(//h2[contains(., &apos;Traffic Rank for&apos;)]/following-sibling::table[position()=1]/tbody/tr[2]/td[2])'/>
          </when>
          <otherwise>
            <value-of select='$daily'/>
          </otherwise>
        </choose>
      </template>
    </transform>
  </template>

  <pages>
    <include>^http://www\.alexa\.com/data/details/traffic_details\?.*url=</include>
  </pages>

  <!-- Update four times a day. -->
  <update interval='360'/>
</generator>
