topical media & game development

talk show tell print

mashup-amazon-10-10-02-Wishlist-xml-amazonCartGet.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">
  <xsl:output method="html"/>  
    <xsl:template match="/">
      <xsl:apply-templates select="a:CartAddResponse" />
      <xsl:apply-templates select="a:CartGetResponse" />
      <xsl:apply-templates select="a:CartCreateResponse" />
      <xsl:apply-templates select="a:CartModifyResponse" />
    </xsl:template>
    
    <xsl:template match="a:CartGetResponse|a:CartCreateResponse|a:CartAddResponse" >
      <xsl:choose>
        <xsl:when test="a:Cart/a:CartItems">
          <xsl:apply-templates select="a:Cart" />
        </xsl:when>
        <xsl:otherwise>
          <!-- there are no cart items -->
          <b>Your Cart exists but is currently empty</b>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:apply-templates select="a:Request/a:Errors" />
    </xsl:template>
  
    <xsl:template match="a:Errors">
      <div class="errors">Errors from Amazon</div>
      <xsl:value-of select="a:Error"/>
    </xsl:template>
    
    <xsl:template match="a:Error">
      <xsl:value-of select="a:Code"/>, 
      <xsl:value-of select="a:Message"/><br/>
    </xsl:template>
    
    <xsl:template match="a:Cart">
      <h3>Cart Summary</h3>
      <h4>Total Price: <xsl:value-of select="a:SubTotal/a:FormattedPrice"></xsl:value-of>,     
        <a>
          <xsl:attribute name="href">
            <xsl:value-of select="a:PurchaseURL"></xsl:value-of>
          </xsl:attribute>
          Click Here to Checkout now
        </a>
      </h4>
      (You will be able to modify your cart and
      enter shipping information before 
      the order is placed).<br/><br/>
      <xsl:apply-templates select="a:CartItems" />
    </xsl:template>
    
    <xsl:template match="a:CartItems" >  
      <h3>Cart Details</h3>
      <xsl:apply-templates select="a:CartItem" />
    </xsl:template>
    
    <xsl:template match="a:CartItem">        
      <b><xsl:value-of select="a:Title"/>:</b> <xsl:value-of select="a:Price/a:FormattedPrice"/><br/>
        ASIN: <a href="javascript:void(0)">        
          <xsl:attribute name="onclick">Lookup('<xsl:value-of select="a:ASIN" />');</xsl:attribute>
        <xsl:value-of select="a:ASIN"/></a> | <xsl:value-of select="a:ProductGroup"/> | Quantity: <xsl:value-of select="a:Quantity"/> | 
      <a href="javascript:void(0)">
        <xsl:attribute name="onclick">
          RemoveFromCart('<xsl:value-of select="a:CartItemId" />');
        </xsl:attribute>
        Remove
      </a>
      <br/>  
    </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.