<?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="eBay Auction Item">

  <pages>
    <include>^http://cgi\.ebay\.com/.*QQitemZ.*QQcmdZViewItem</include>
    <include>^http://cgi\.ebay\.com/ws/eBayISAPI\.dll\?ViewItem&amp;.*item=</include>
  </pages>

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

        <!-- The name of the item.
           -
           - To conserve space, we only show the first seven characters.
           - Note that we call normalize-space twice.  The inner one strips
           - leading whitespace before we truncate the string so it doesn't
           - count in the seven characters.  The outer one strips trailing
           - whitespace after we truncate the string, to prevent there being
           - a space between the name and the succeeding colon on the off
           - chance the seventh character is a space.
           -->
        <value-of select="normalize-space(substring(normalize-space(/html/body/span[1]/table[1]//tr/td/table[2]//tr[2]/td[4]/h1), 1, 7))"/>
        <text>: </text>

        <!-- The current bid.
           -
           - The current bid is sometimes succeeded by a non-breaking space
           - (&#160;).  Unfortunately, due to Mozilla bug 342273, microsummaries
           - with non-breaking spaces cannot be selected in a drop-down menu
           - like the one for selecting a live title in the bookmark dialogs,
           - so we have to translate non-breaking spaces into regular spaces.
           -->
        <value-of select="normalize-space(translate(id('DetailsCurrentBidValue'), '&#160;', ' '))"/>
        <text>, </text>

        <!-- The time remaining in the auction.
           -
           - eBay puts this inside different descendants of the tag with the ID
           - 'DetailsTimeLeft' depending on whether the auction is ending
           - within the day or more than a day away, so we find it by looking
           - for the content containing one or more of the strings "day",
           - "hour", "min", and "sec".
           -
           - As with the current bid, we translate non-breaking spaces into
           - regular spaces, but we also strip parentheses, which enclose
           - the time remaining for auctions ending more than a day away.
           -
           - For auctions that have already ended, we just display "ended".
           -->
        <variable name="time" select="normalize-space(translate(id('DetailsTimeLeft')/*[contains(., 'day') or contains(.,'hour') or contains(.,'min') or contains(.,'sec')], '&#160;()', ' '))"/>
        <variable name="ended" select="id('FastVIPDetails')/table//tr[td='Ended:']"/>
        <choose>
          <when test="$ended != ''">
            <text>ended</text>
          </when>
          <otherwise>
            <value-of select="$time"/>
          </otherwise>
        </choose>

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

</generator>

