<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aws="http://webservices.amazon.com/AWSECommerceService/2008-03-03">
<xsl:output method="html" encoding="UTF-8" indent="no" />

<xsl:variable name="starurl">http://g-ec2.images-amazon.com/images/G/09/x-locale/common/customer-reviews/</xsl:variable>

<xsl:template match="/">
  document.write('<table border="0" cellpadding="5" class="aws_items">');
  document.write('<xsl:apply-templates select="aws:ItemLookupResponse/aws:Items/aws:Item"/>');
  document.write('</table>');
</xsl:template>

<xsl:template match="aws:ItemLookupResponse/aws:Items/aws:Item">
  <tr>
  <td valign="top" class="aws_img">
    <xsl:element name="a">
      <xsl:attribute name="href"><xsl:value-of select="aws:DetailPageURL" /></xsl:attribute>
      <xsl:attribute name="target">_blank</xsl:attribute>
        <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:attribute name="border">0</xsl:attribute>
        </xsl:element>
    </xsl:element>
  </td>
  <td valign="top" class="aws_attr">
    <xsl:element name="a">
      <xsl:attribute name="href"><xsl:value-of select="aws:DetailPageURL" /></xsl:attribute>
      <xsl:attribute name="target">_blank</xsl:attribute>
      <xsl:value-of select="aws:ItemAttributes/aws:Title" />
    </xsl:element>
  <br />
  <xsl:apply-templates select="aws:ItemAttributes/aws:Author"/>
  <br />
  <b><xsl:value-of select="aws:OfferSummary/aws:LowestNewPrice/aws:FormattedPrice" />(税込)</b>
  
  <div class="aws_review">
  <xsl:apply-templates select="aws:CustomerReviews"/>
  <br />
  <xsl:apply-templates select="aws:CustomerReviews/aws:Review"/>
  </div>
  </td>
  </tr>
</xsl:template>

<xsl:template match="aws:ItemAttributes/aws:Author">
  <xsl:if test="position() &lt; 4">
    <xsl:if test="position() &gt; 1">, </xsl:if>
    <xsl:value-of select="text()" />
  </xsl:if>
  <xsl:choose>
  <xsl:when test="position() = 4">, 他</xsl:when>
  </xsl:choose>
</xsl:template>

<xsl:template match="aws:CustomerReviews">
  <b>おすすめ度（平均）：</b>
  <xsl:variable name="rating" select="aws:AverageRating" />
  <xsl:choose>
    <xsl:when test="$rating = 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="$rating = 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="$rating = 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="$rating = 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="$rating = 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="$rating = 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="$rating = 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="$rating = 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="$rating = 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>
</xsl:template>

<xsl:template match="aws:CustomerReviews/aws:Review">
  <xsl:if test="position() &lt; 4">
  <xsl:variable name="rating" select="aws:Rating" />
  <xsl:choose>
    <xsl:when test="$rating = 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="$rating = 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="$rating = 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="$rating = 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="$rating = 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="$rating = 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="$rating = 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="$rating = 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="$rating = 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>
  <xsl:element name="span"><xsl:value-of select="aws:Summary" /></xsl:element>
  
  <br />
  </xsl:if>
</xsl:template>
</xsl:stylesheet>
