topical media & game development

talk show tell print

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



  <?xml version="1.0" encoding="UTF-8"?>
  <xsl:stylesheet version="1.0" 
    xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:tns="http://www.w3.org/1999/xhtml" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:a="http://webservices.amazon.com/AWSECommerceService/2005-10-05">
    <xsl:output method="html" />
    <xsl:template match="/">
      <xsl:apply-templates select="a:ListLookupResponse"/>    
    </xsl:template>
  
    <xsl:template match="a:ListLookupResponse">
      <h2>WishList Details</h2>
      <xsl:apply-templates select="a:Lists"/>
    </xsl:template>
  
    <xsl:template match="a:Lists">    
      <xsl:apply-templates select="a:List"/>
    </xsl:template>
  
    <!-- The List template -->
    <xsl:template match="a:List">
      <h2>
        List Id: <xsl:value-of select="a:ListId"/>
      </h2>
      <table>
        <xsl:apply-templates select="a:ListItem/a:Item"/>
      </table>
    </xsl:template>
  
    <xsl:template match="a:Item">
      <tr>
        <td>
      <img align="left">
        <xsl:choose>
          <xsl:when test="a:SmallImage/a:URL">
            <xsl:attribute name="src">
              <xsl:value-of select="a:SmallImage/a:URL" />
            </xsl:attribute>
            <xsl:attribute name="width">
              <xsl:value-of select="a:SmallImage/a:Width" />
            </xsl:attribute>
            <xsl:attribute name="height">
              <xsl:value-of select="a:SmallImage/a:Height" />
            </xsl:attribute>
          </xsl:when>
          <xsl:otherwise>
            <!-- there are no small image, time to search -->
            <xsl:attribute name="src">images/noimage.gif</xsl:attribute>
          </xsl:otherwise>
        </xsl:choose>
      </img>
      <b><xsl:value-of select="a:ItemAttributes/a:Title" /></b><br/>
      <a target="_blank">
        <xsl:attribute name="href">
          <xsl:value-of select="a:DetailPageURL" />
        </xsl:attribute>
        Visit on Amazon
      </a>
          or 
          <a href="javascript:void(0)">
            <xsl:attribute name="onclick">EbaySearch('<xsl:value-of select="a:ItemAttributes/a:Title"/>');</xsl:attribute>
            Search for it on Ebay
          </a>
          or 
          <a href="javascript:void(0)">
            <xsl:attribute name="onclick">AddToCart('<xsl:value-of select="a:ASIN"/>');</xsl:attribute>
            Add to Remote Cart
          </a>
        </td>
      </tr>    
    </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.