﻿<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">
  <xsl:output method="html" encoding="utf-8"/>
  <xsl:template match="/">
<xsl:apply-templates select="ProductInfo/Details" />
</xsl:template>

<xsl:template match="Details">
<xsl:variable name="listprice" select="ListPrice" />
<xsl:variable name="ourprice" select="OurPrice" />
<xsl:variable name="availavility" select="Availability" />

<html lang="ja"><head>
<meta http-equiv="Content-Style-Type" content="text/css" />
<link rel="stylesheet" href="http://sonic64.com/diary.css" media="all" />
<title>Landscape: Amazon webservice stylesheet</title>
</head><body class="aff_xsl">
定価: <xsl:value-of select="$listprice"/><br />

<xsl:variable name="num_listprice" select="number(translate(translate($listprice, '￥', ''), ',', ''))"/>
<xsl:variable name="num_ourprice" select="number(translate(translate($ourprice, '￥', ''), ',', ''))"/>
<xsl:variable name="discount" select="$num_listprice - $num_ourprice"/>

<xsl:choose>
  <xsl:when test="0 &lt; $discount">
    <noscript>「<xsl:value-of select="ProductName" />」の</noscript> amazon 価格: <span class="aff_discount"><xsl:value-of select="$ourprice"/> (<xsl:value-of select="round(($discount div $num_listprice) * 100)" />% 引き)</span>
  </xsl:when>
  <xsl:otherwise>
    <noscript>「<xsl:value-of select="ProductName" />」の</noscript> amazon 価格: <xsl:value-of select="$ourprice"/>
  </xsl:otherwise>
</xsl:choose>
<br />

<xsl:choose>
  <xsl:when test="1500 &lt;= $num_ourprice">
    amazon 送料: <span class="aff_shipping">単品の注文でも </span> <span class="aff_discount">送料無料</span>
  </xsl:when>
  <xsl:otherwise>
    amazon 送料: <span class="aff_shipping">注文合計額1500円で送料無料 (あと<xsl:value-of select="1500 - $num_ourprice" />円)</span>
  </xsl:otherwise>
</xsl:choose>
<br />

<noscript>「<xsl:value-of select="ProductName" />」の</noscript> amazon 在庫状況: <span class="aff_avail"><xsl:value-of select="$availavility"/></span><br />
<noscript><a href="http://sonic64.com/" title="Landscape - エンジニアのメモ">Landscape - エンジニアのメモ</a></noscript>
</body></html>
</xsl:template>

</xsl:stylesheet>
