<generator name='Yahoo! Finance Stock Quote w/Change' xmlns='http://www.mozilla.org/microsummaries/0.1'>

  <pages>
    <include>^http://finance\.yahoo\.com/q\?.*s=[a-zA-Z0-9%]+</include>
  </pages>

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

        <!-- The stock ticker symbol.  The symbol is only available as part of
           - a text node that also contains the full company name, but the symbol
           - is in parentheses in that node, so we use substring functions
           - to extract the symbol from within the parentheses.
           -->
        <value-of select='substring-before(substring-after(string(id(&apos;yfncsubtit&apos;)/tbody/tr/td[1]/b), &apos;(&apos;), &apos;)&apos;)'/>

        <text>: </text>

        <!-- The stock price.  The location of this value can fluctuate,
           - but it is always labeled "Last Trade:", so we look for that label
           - and use the value in the next cell.
           -->
        <value-of select='//table/tbody/tr[td=&apos;Last Trade:&apos;]/td[2]'/>

        <!-- The direction and change in the price of the stock.  Yahoo displays
           - the direction via an image of an arrow that has an "alt" attribute
           - set to either "Up" or "Down".  We test the value of that attribute
           - and display either "+" or "-" in the microsummary.
           -->
        <variable name='direction' select='//table/tbody/tr[td=&apos;Change:&apos;]/td[2]//img/attribute::alt'/>
        <variable name='change' select='normalize-space(//table/tbody/tr[td=&apos;Change:&apos;]/td[2])'/>

        <choose>
          <when test='$direction = &apos;Up&apos;'>
            <text> + </text>
            <value-of select='$change'/>
          </when>
          <when test='$direction = &apos;Down&apos;'>
            <text> - </text>
            <value-of select='$change'/>
          </when>
          <otherwise/>
        </choose>

      </template>
    </transform>
  </template>

</generator>
