topical media & game development

talk show tell print

mashup-amazon-10-10-02-Wishlist-xml-ebaySearch.xsl / xsl



  <?xml version="1.0" encoding="UTF-8"?>
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:n="urn:ebay:apis:eBLBaseComponents">
  <xsl:output method="html"/>
  <xsl:template match="/">
    <h2>Ebay Results</h2>
    <xsl:choose>
      <xsl:when test="n:GetSearchResultsResponse/n:SearchResultItemArray">  
        <xsl:apply-templates select="n:GetSearchResultsResponse/n:SearchResultItemArray"/>  
      </xsl:when>
    <xsl:otherwise><!-- there are no children, time to search -->
      <span class="t">Sorry your search returned no results.</span><br/>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:apply-templates select="n:GetSearchResultsResponse/n:Errors/n:ShortMessage" />
  </xsl:template>
    
    <xsl:template match="n:GetSearchResultsResponse/n:Errors/n:ShortMessage">
      <br/>
      Ebay returned the following errors: <br/>
      <xsl:value-of select="." />
    </xsl:template>
    
    <xsl:template match="n:GetSearchResultsResponse/n:SearchResultItemArray">
      <table border="0">
      <xsl:apply-templates select="n:SearchResultItem" />
      </table>
    </xsl:template>
    
    <xsl:template match="n:SearchResultItem">    
      <xsl:apply-templates select="n:Item" />     
    </xsl:template>
    
    <xsl:template match="n:Item">
      <tr><td>
      <xsl:apply-templates select="n:PictureDetails" />
        </td><td>
        <b><xsl:value-of select="n:Title" /></b><br/>
          <xsl:apply-templates select="n:ListingDetails" /> 
      Item ID: <xsl:value-of select="n:ItemID" /><br/>        
         <xsl:apply-templates select="n:BuyItNowPrice" />
        <xsl:apply-templates select="n:SellingStatus" /></td></tr>
    </xsl:template>
      
    <xsl:template match="n:BuyItNowPrice">     
      <b>Buy It Now Price: <xsl:value-of select="." /></b><br/>
    </xsl:template>
    
    <xsl:template match="n:ListingDetails">
       [ <a target="_blank"><xsl:attribute name="href">
        <xsl:value-of select="n:ViewItemURL" />
      </xsl:attribute>View on eBay</a> ]<br/>
    </xsl:template>
    
    <xsl:template match="n:SellingStatus">    
        Number of Bids: <xsl:value-of select="n:BidCount" /><br/>
        Current Price: <span class="c"><xsl:value-of select="n:CurrentPrice" /></span><br/>
        <xsl:apply-templates select="n:Item" />
    </xsl:template>
    
    <xsl:template match="n:PictureDetails">
      <img align="left"><xsl:attribute name="src"><xsl:value-of select="n:GalleryURL" /></xsl:attribute></img>
    </xsl:template>
  </xsl:stylesheet>


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.