<?xml version="1.0"?>
<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:aws="http://xml.amazon.com/AWSECommerceService/2004-10-04"
  version="1.0">
  <xsl:output method="html" encoding="utf-8"/>

<xsl:template match="/">
	<html>
	<head>
	<title>amazon</title>
	<link>
		<xsl:attribute name="rel">stylesheet</xsl:attribute>
		<xsl:attribute name="type">text/css</xsl:attribute>
		<xsl:attribute name="charset">UTF-8</xsl:attribute>
		<xsl:attribute name="href">http://fuba.s7.xrea.com/nifuba.css</xsl:attribute>
	</link>
	</head>
	<body class="amazon_ad">
	<div class="amazon_mode">
	<xsl:apply-templates select="aws:ItemLookupResponse/aws:Items" />
	</div>
	</body>
	</html>
</xsl:template>


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

<xsl:template match="aws:Item">
	<form>
		<xsl:attribute name="target">_blank</xsl:attribute>
		<xsl:attribute name="class">amazon_item</xsl:attribute>
		<xsl:attribute name="method">GET</xsl:attribute>
		<xsl:attribute name="action">http://www.amazon.co.jp/gp/aws/cart/add.html</xsl:attribute>
	<input>
		<xsl:attribute name="type">hidden</xsl:attribute>
		<xsl:attribute name="name">AssociateTag</xsl:attribute>
		<xsl:attribute name="value">nifuba-22</xsl:attribute>
	</input>
	<input>
		<xsl:attribute name="type">hidden</xsl:attribute>
		<xsl:attribute name="name">SubscriptionId</xsl:attribute>
		<xsl:attribute name="value">1RTHSTV200503SRH4RR2</xsl:attribute>
	</input> 
	<xsl:variable name="asin" select="aws:ASIN" />
	<xsl:variable name="name" select="aws:ItemAttributes/aws:Title" />
	<xsl:variable name="associate_id">nifuba-22</xsl:variable>
		
	<xsl:variable name="url">http://www.amazon.co.jp/exec/obidos/ASIN/<xsl:value-of select="$asin" />/<xsl:value-of select="$associate_id" />/ref=nosim/</xsl:variable>
	
	<div>
		<xsl:attribute name="class">amazon_item_small</xsl:attribute>
		<a>
			<xsl:attribute name="target">_blank</xsl:attribute>
			<xsl:attribute name="title"><xsl:value-of select="$name"/></xsl:attribute>
			<xsl:attribute name="href">
				<xsl:value-of select="$url" />
			</xsl:attribute>
			<xsl:apply-templates select="aws:SmallImage" />
		</a>
		<input>
			<xsl:attribute name="type">hidden</xsl:attribute>
			<xsl:attribute name="name">ASIN.<xsl:number level="any" from="aws:MultiOperationResponse" /></xsl:attribute>
			<xsl:attribute name="value"><xsl:value-of select="$asin" /></xsl:attribute>
		</input>
		<input>
			<xsl:attribute name="type">hidden</xsl:attribute>
			<xsl:attribute name="name">Quantity.<xsl:number level="any" from="aws:MultiOperationResponse" /></xsl:attribute>
			<xsl:attribute name="id">quantity_<xsl:number level="any" from="aws:MultiOperationResponse" /></xsl:attribute>
			<xsl:attribute name="value">1</xsl:attribute>
		</input>
		<a>
			<xsl:attribute name="target">_blank</xsl:attribute>
			<xsl:attribute name="href">
				<xsl:value-of select="$url" />
			</xsl:attribute>
			<xsl:choose>
				<xsl:when test="string-length($name)&gt;30">
					[<xsl:value-of select="aws:ItemAttributes/aws:ProductGroup"/>]<xsl:value-of select="substring($name,1,30)"/>…
				</xsl:when>
				<xsl:otherwise>
					[<xsl:value-of select="aws:ItemAttributes/aws:ProductGroup"/>]<xsl:value-of select="$name"/>
				</xsl:otherwise>
			</xsl:choose>
			
		</a><br />
		<xsl:apply-templates select="aws:ItemAttributes" />
		<xsl:apply-templates select="aws:Offers/aws:Offer/aws:OfferListing" />
	</div>
	<div>
		<xsl:attribute name="class">amazon_item_small_button</xsl:attribute>
		<button>
			<xsl:attribute name="type">submit</xsl:attribute>
			<xsl:attribute name="class">button_single</xsl:attribute>
			<img>
				<xsl:attribute name="alt">Amazon.co.jpで買う</xsl:attribute>
				<xsl:attribute name="src">http://rcm-images.amazon.com/images/G/09/buttons/buy-from-tan.gif</xsl:attribute>
			</img>
		</button>
	</div>
	</form>
</xsl:template>

<xsl:template match="aws:SmallImage">
	<img>
		<xsl:attribute name="src">
			<xsl:value-of select="aws:URL" />
		</xsl:attribute>
	</img>
</xsl:template>

<xsl:template match="aws:OfferListing">
	<xsl:variable name="ourprice" select="aws:Price/aws:FormattedPrice" />
	<xsl:variable name="availavility" select="aws:Availability" />
	
	<xsl:value-of select="$ourprice"/><br />
	<xsl:value-of select="$availavility"/><br />
</xsl:template>

<xsl:template match="aws:ItemAttributes">
	<xsl:apply-templates select="aws:Author" />
	<xsl:apply-templates select="aws:ReleaseDate" />
	<xsl:apply-templates select="aws:PublicationDate" />
</xsl:template>

<xsl:template match="aws:Author">
	<xsl:value-of select="." /><br />
</xsl:template>

<xsl:template match="aws:ReleaseDate">
	発売日: <xsl:value-of select="." /><br />
</xsl:template>

<xsl:template match="aws:PublicationDate">
	発売日: <xsl:value-of select="." /><br />
</xsl:template>

<!-- ユーズド価格の表示 -->
<!-- <xsl:template match="aws:OfferSummary/aws:LowestUsedPrice">
	<xsl:variable name="used" select="aws:FormattedPrice" />
	<li>Used: <xsl:value-of select="$used"/></li>
</xsl:template> -->

</xsl:stylesheet>

