
<xsl:stylesheet    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"    xmlns:aws="http://webservices.amazon.com/AWSECommerceService/2009-07-01"   version="1.0">
<xsl:output method="html" encoding="Shift_JIS"/>

<xsl:template match="/">
  <html lang="ja">
  <head>
  <title>XSLサンプル</title>
  </head>
  <body>

  <xsl:apply-templates select="aws:ItemSearchResponse/aws:Items/aws:Item"/>

  </body>
  </html>
</xsl:template>

<xsl:template match="aws:ItemSearchResponse/aws:Items/aws:Item">
  <p>
  <xsl:element name="img">
    <xsl:attribute name="src">
      <xsl:value-of select="aws:ImageSets/aws:ImageSet/aws:MediumImage/aws:URL" />
    </xsl:attribute>
    <xsl:attribute name="width">
      <xsl:value-of select="aws:ImageSets/aws:ImageSet/aws:MediumImage/aws:Width" />
    </xsl:attribute>
    <xsl:attribute name="height">
      <xsl:value-of select="aws:ImageSets/aws:ImageSet/aws:MediumImage/aws:Height" />
    </xsl:attribute>
    <xsl:attribute name="alt">
      <xsl:value-of select="aws:ItemAttributes/aws:Title" />
    </xsl:attribute>
  </xsl:element>
  </p>

  <p>
  <xsl:variable name="starurl">http://g-ec2.images-amazon.com/images/G/09/x-locale/common/customer-reviews/</xsl:variable>
  <xsl:choose>
    <xsl:when test="aws:CustomerReviews/aws:AverageRating = 5.0">
      [おすすめ度] 
      <xsl:element name="img">
        <xsl:attribute name="src">
          <xsl:value-of select="concat($starurl,'stars-5-0._V45731007_.gif')" />
        </xsl:attribute>
      </xsl:element>
    </xsl:when>
    <xsl:when test="aws:CustomerReviews/aws:AverageRating = 4.5">
      [おすすめ度] 
      <xsl:element name="img">
        <xsl:attribute name="src">
          <xsl:value-of select="concat($starurl,'stars-4-5._V45727989_.gif')" />
        </xsl:attribute>
      </xsl:element>
    </xsl:when>
    <xsl:when test="aws:CustomerReviews/aws:AverageRating = 4.0">
      [おすすめ度] 
      <xsl:element name="img">
        <xsl:attribute name="src">
          <xsl:value-of select="concat($starurl,'stars-4-0._V45729814_.gif')" />
        </xsl:attribute>
      </xsl:element>
    </xsl:when>
    <xsl:when test="aws:CustomerReviews/aws:AverageRating = 3.5">
      [おすすめ度] 
      <xsl:element name="img">
        <xsl:attribute name="src">
          <xsl:value-of select="concat($starurl,'stars-3-5._V45728391_.gif')" />
        </xsl:attribute>
      </xsl:element>
    </xsl:when>
    <xsl:when test="aws:CustomerReviews/aws:AverageRating = 3.0">
      [おすすめ度] 
      <xsl:element name="img">
        <xsl:attribute name="src">
          <xsl:value-of select="concat($starurl,'stars-3-0._V45728225_.gif')" />
        </xsl:attribute>
      </xsl:element>
    </xsl:when>
    <xsl:when test="aws:CustomerReviews/aws:AverageRating = 2.5">
      [おすすめ度] 
      <xsl:element name="img">
        <xsl:attribute name="src">
          <xsl:value-of select="concat($starurl,'stars-2-5._V45728383_.gif')" />
        </xsl:attribute>
      </xsl:element>
    </xsl:when>
    <xsl:when test="aws:CustomerReviews/aws:AverageRating = 2.0">
      [おすすめ度] 
      <xsl:element name="img">
        <xsl:attribute name="src">
          <xsl:value-of select="concat($starurl,'stars-2-0._V45731245_.gif')" />
        </xsl:attribute>
      </xsl:element>
    </xsl:when>
    <xsl:when test="aws:CustomerReviews/aws:AverageRating = 1.5">
      [おすすめ度] 
      <xsl:element name="img">
        <xsl:attribute name="src">
          <xsl:value-of select="concat($starurl,'stars-1-5._V45730841_.gif')" />
        </xsl:attribute>
      </xsl:element>
    </xsl:when>
    <xsl:when test="aws:CustomerReviews/aws:AverageRating = 1.0">
      [おすすめ度] 
      <xsl:element name="img">
        <xsl:attribute name="src">
          <xsl:value-of select="concat($starurl,'stars-1-0._V45727811_.gif')" />
        </xsl:attribute>
      </xsl:element>
    </xsl:when>
  </xsl:choose>
  </p>

  <xsl:apply-templates select="aws:CustomerReviews/aws:Review"/>
</xsl:template>

<xsl:template match="aws:CustomerReviews/aws:Review">
  <p>
  <xsl:variable name="starurl">http://g-ec2.images-amazon.com/images/G/09/x-locale/common/customer-reviews/</xsl:variable>
  <xsl:choose>
    <xsl:when test="aws:Rating = 5">
      <xsl:element name="img">
        <xsl:attribute name="src">
          <xsl:value-of select="concat($starurl,'stars-5-0._V45731007_.gif')" />
        </xsl:attribute>
      </xsl:element>
    </xsl:when>
    <xsl:when test="aws:Rating = 4">
      <xsl:element name="img">
        <xsl:attribute name="src">
          <xsl:value-of select="concat($starurl,'stars-4-0._V45729814_.gif')" />
        </xsl:attribute>
      </xsl:element>
    </xsl:when>
    <xsl:when test="aws:Rating = 3">
      <xsl:element name="img">
        <xsl:attribute name="src">
          <xsl:value-of select="concat($starurl,'stars-3-0._V45728225_.gif')" />
        </xsl:attribute>
      </xsl:element>
    </xsl:when>
    <xsl:when test="aws:Rating = 2">
      <xsl:element name="img">
        <xsl:attribute name="src">
          <xsl:value-of select="concat($starurl,'stars-2-0._V45731245_.gif')" />
        </xsl:attribute>
      </xsl:element>
    </xsl:when>
    <xsl:when test="aws:Rating = 1">
      <xsl:element name="img">
        <xsl:attribute name="src">
          <xsl:value-of select="concat($starurl,'stars-1-0._V45727811_.gif')" />
        </xsl:attribute>
      </xsl:element>
    </xsl:when>
  </xsl:choose>
  <xsl:value-of select="aws:Summary" />
  </p>
</xsl:template>

</xsl:stylesheet>