topical media & game development

talk show tell print

mashup-amazon-13-13-05-GoogleAmazon-AmazonGoogle.xsl / xsl



  <?xml version="1.0" encoding="UTF-8"?>
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:a="http://webservices.amazon.com/AWSECommerceService/2005-10-05" 
    xmlns:y="urn:yahoo:prods" xmlns:e="urn:ebay:apis:eBLBaseComponents" 
    xmlns:g="urn:google:search">
    <!-- Define a parameter -->
    <xsl:param name="resultPage"></xsl:param>
  
    <xsl:output method="xml" encoding="ISO-8859-1" omit-xml-declaration="yes"/>
    <xsl:template match="/">
      <rss version="2.0" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" >
        <channel>
          <title>AMZN + GOOGLE Search Results</title>
          <link>http://Mashups.FrancisShanahan.com>
          <description>Syndicated Amazon and Google Results</description>
          <language>en-us</language>
          <generator>Francis Shanahan[.com]</generator>
          <managingEditor>dotnet@francisshanahan.com</managingEditor>
          <xsl:apply-templates select="MyMashup/a:ItemSearchResponse/a:Items/a:Item"/>
          <xsl:apply-templates select="MyMashup/e:GetSearchResultsResponse/e:SearchResultItemArray"/>
          <xsl:apply-templates select="MyMashup/g:MyGoogle/g:item"/>
          <openSearch:startIndex>
            <xsl:value-of select="resultPage"/>
          </openSearch:startIndex>
          <openSearch:itemsPerPage>20</openSearch:itemsPerPage>
          <openSearch:totalResults>
            <xsl:value-of select="MyMashup/a:ItemSearchResponse/a:Items/a:TotalResults"/>
          </openSearch:totalResults>
        </channel>
      </rss>
    </xsl:template>
  
    <xsl:template match="a:Item">
      <item>
        <title>
          Amazon: <xsl:value-of select="a:ItemAttributes/a:Title" />
        </title>
        <description>
          &lt;img src="<xsl:value-of select="a:SmallImage/a:URL" />" alt="<xsl:value-of select="a:ItemAttributes/a:Title" />" title="<xsl:value-of select="a:ItemAttributes/a:Title" />" align="left" /&gt;
          <xsl:apply-templates select="a:OfferSummary"/>
          <xsl:apply-templates select="a:ItemAttributes"/>
          <xsl:apply-templates select="a:EditorialReviews/a:EditorialReview"/>
        </description>
        <link>
          <xsl:value-of select="a:DetailPageURL" />
        </link>
      </item>
    </xsl:template>
  
    <!-- Google Stuff -->
    <xsl:template match="g:item">
      <item>
        <title>
          Google: <xsl:value-of select="g:title" />
        </title>
        <description>
          <xsl:value-of select="g:description" />
        </description>
        <link>
          <xsl:value-of select="g:link" />
        </link>
      </item>
    </xsl:template>
  
    <!-- Amazon stuff follows -->
    <xsl:template match="a:OfferSummary">
      &lt;b&gt;Lowest Price:&lt;/b&gt;<xsl:value-of select="a:LowestNewPrice/a:FormattedPrice" /> |
      &lt;b&gt;Total New:&lt;/b&gt;<xsl:value-of select="a:TotalNew" /> |
      &lt;b&gt;Total Used:&lt;/b&gt;<xsl:value-of select="a:TotalUsed" /> |
      &lt;b&gt;Total Used:&lt;/b&gt;<xsl:value-of select="a:TotalUsed" /> |
      &lt;b&gt;Total Collectible:&lt;/b&gt;<xsl:value-of select="a:TotalCollectible" /> |
      &lt;b&gt;Total Refurbished:&lt;/b&gt;<xsl:value-of select="a:TotalRefurbished" />&lt;br/&gt;
    </xsl:template>
  
    <xsl:template match="a:ItemAttributes">
      &lt;b&gt;List Price:&lt;/b&gt;<xsl:value-of select="a:ListPrice/a:FormattedPrice" /> |
      <xsl:apply-templates select="a:Feature"/>
      <xsl:apply-templates select="a:Director"/>
      <xsl:apply-templates select="a:Actor"/>
    </xsl:template>
  
    <xsl:template match="a:Feature">
      &lt;li&gt;<xsl:value-of select="." />&lt;/li&gt;
    </xsl:template>
    <xsl:template match="a:Director">
      Director: <xsl:value-of select="."/>&lt;br/&gt;
    </xsl:template>
    <xsl:template match="a:Actor">
      Actor: <xsl:value-of select="."/>&lt;br/&gt;
    </xsl:template>
    <xsl:template match="a:EditorialReviews/a:EditorialReview">
      Editorial Review: <xsl:value-of select="a:Source"/>&lt;br/&gt;
      <xsl:value-of select="a:Content"/>&lt;br/&gt;
    </xsl:template>
  
    <!-- Yahoo stuff follows -->
    <xsl:template match="y:Result/y:Catalog">
      <item>
        <title>
          Yahoo: <xsl:value-of select="y:ProductName" />
        </title>
        <description>
          &lt;img src="<xsl:value-of select="y:Thumbnail/y:Url" />" alt="<xsl:value-of select="y:ProductName" />" title="<xsl:value-of select="y:ProductName" />" align="left" width="<xsl:value-of select="y:Thumbnail/y:Width" />" height="<xsl:value-of select="y:Thumbnail/y:Height" />"/&gt;
          &lt;b&gt;Prices from &lt;/b&gt;<xsl:value-of select="y:PriceFrom"/> to <xsl:value-of select="y:PriceTo"/>&lt;br/&gt;
          <xsl:value-of select="y:Description" />
        </description>
  
        <link>
          <xsl:value-of select="y:Url" />
        </link>
      </item>
    </xsl:template>
  
    <!-- Ebay stuff follows -->
    <xsl:template match="e:GetSearchResultsResponse/e:SearchResultItemArray">
      <xsl:apply-templates select="e:SearchResultItem" />
    </xsl:template>
  
    <xsl:template match="e:SearchResultItem">
      <xsl:apply-templates select="e:Item" />
    </xsl:template>
  
    <xsl:template match="e:Item">
      <item>
        <title>
          eBay: <xsl:value-of select="e:Title" />
        </title>
        <description>
          <xsl:apply-templates select="e:VendorHostedPicture" /><xsl:value-of select="e:Title" />&lt;br/&gt;
          Item ID: <xsl:value-of select="e:ItemID" />&lt;br/&gt;
          <xsl:apply-templates select="e:BuyItNowPrice" />
          <xsl:apply-templates select="e:SellingStatus" />
        </description>
        <link>
          <xsl:value-of select="e:ListingDetails/e:ViewItemURL" />
        </link>
      </item>
    </xsl:template>
  
    <xsl:template match="e:BuyItNowPrice">
      Buy It Now Price: <xsl:value-of select="." /> &lt;br/&gt;
    </xsl:template>
  
    <xsl:template match="e:SellingStatus">
      Number of Bids: <xsl:value-of select="e:BidCount" />&lt;br/&gt;
      Current Price: <xsl:value-of select="e:CurrentPrice" />&lt;br/&gt;
    </xsl:template>
  
    <xsl:template match="e:VendorHostedPicture">
      &lt;img align="left" src="<xsl:value-of select="e:GalleryURL" />" &gt;
    </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.