home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / bookInfo2xhtml.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  7.6 KB  |  242 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17. <xsl:stylesheet 
  18.   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  19.   version="1.0">
  20.  
  21.   <xsl:output method="xml" version="1.0" 
  22.       encoding="UTF-8" indent="yes" 
  23.       omit-xml-declaration="no" 
  24.       doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"  
  25.       doctype-system="DTD/xhtml1-strict.dtd"/>
  26.       
  27.   <xsl:template match="/">
  28.         <xsl:apply-templates select="ProductInfo/Details"/>
  29.   </xsl:template>
  30.   
  31.   <xsl:template match="Details">
  32.     <table border="0" width="100%" cellpadding="5">
  33.       <tr>
  34.         <td rowspan="4">
  35.           <img src="{ImageUrlMedium}"/>
  36.         </td>
  37.         <td>
  38.           <b><u><font size="+1"><xsl:value-of select="ProductName"/></font></u></b>
  39.         </td>
  40.       </tr>
  41.       <tr>
  42.         <td>
  43.           <b>
  44.             <xsl:text>Published: </xsl:text>
  45.           </b>
  46.           <xsl:value-of select="ReleaseDate"/>
  47.         </td>
  48.       </tr>
  49.       <tr>
  50.         <td>
  51.           <xsl:call-template name="OurPrice">
  52.             <xsl:with-param name="OurPrice" 
  53.               select="substring(OurPrice, 2)"/>
  54.             <xsl:with-param name="ListPrice" 
  55.               select="substring(ListPrice, 2)"/>
  56.           </xsl:call-template>
  57.           <xsl:apply-templates select="UsedPrice | CollectiblePrice | ThirdPartyNewPrice"/> 
  58.           <xsl:apply-templates select="SalesRank"/>
  59.         </td>
  60.       </tr>
  61.       <tr>
  62.         <td>
  63.           <xsl:apply-templates select="Authors"/>
  64.         </td>
  65.       </tr>
  66.       <tr>
  67.         <td>
  68.           <xsl:call-template name="BuyButton">
  69.             <xsl:with-param name="Asin" 
  70.               select="Asin"/>
  71.           </xsl:call-template>
  72.         </td>
  73.       </tr>
  74.       <xsl:apply-templates select="Reviews/AvgCustomerRating"/>
  75.       <xsl:apply-templates select="Reviews/CustomerReview">
  76.         <xsl:sort select="Rating"/>
  77.       </xsl:apply-templates>
  78.     </table>
  79.     <hr/>
  80.   </xsl:template>
  81.  
  82.   <xsl:template name="OurPrice">
  83.     <xsl:param name="OurPrice"  select="'1.00'"/>
  84.     <xsl:param name="ListPrice" select="'1.00'"/>
  85.     <xsl:param name="UsedPrice"/>
  86.     <xsl:param name="CollectiblePrice"/>
  87.     <xsl:param name="ThirdPartyNewPrice"/>
  88.  
  89.     <xsl:choose>
  90.       <xsl:when test="$OurPrice = $ListPrice">
  91.         <b>Our price: </b><xsl:text>$</xsl:text>
  92.         <xsl:value-of select="$OurPrice"/>
  93.       </xsl:when>
  94.       <xsl:otherwise>
  95.         <b>Our price: </b><xsl:text>$</xsl:text>
  96.         <xsl:value-of select="$OurPrice"/>
  97.         <br />
  98.         <b>List price: </b><xsl:text>$</xsl:text>
  99.         <xsl:value-of select="$ListPrice"/>
  100.         <xsl:text> (</xsl:text>
  101.         <i>that's </i>
  102.         <b>
  103.           <xsl:value-of select="100 - round(($OurPrice div $ListPrice) * 100)"/>
  104.           <xsl:text>%</xsl:text>
  105.         </b>
  106.         <i> off!</i>
  107.         <xsl:text>)</xsl:text>
  108.       </xsl:otherwise>
  109.     </xsl:choose>
  110.   </xsl:template>
  111.  
  112.   <xsl:template match="SalesRank">
  113.     <br />
  114.     <b>
  115.       <xsl:text>Sales rank: </xsl:text>
  116.       <xsl:value-of select="."/>
  117.     </b>
  118.   </xsl:template>
  119.  
  120.   <xsl:template match="UsedPrice">
  121.     <br />
  122.     <b>Used price: </b>
  123.     <xsl:value-of select="."/>
  124.   </xsl:template>
  125.  
  126.   <xsl:template match="CollectiblePrice">
  127.     <br />
  128.     <b>Collectible price: </b>
  129.     <xsl:value-of select="."/>
  130.   </xsl:template>
  131.  
  132.   <xsl:template match="ThirdPartyNewPrice">
  133.     <br />
  134.     <b>Buy one from zShops for: </b>
  135.     <xsl:value-of select="."/>
  136.   </xsl:template>
  137.  
  138.   <xsl:template match="Authors">
  139.     <xsl:choose>
  140.       <xsl:when test="count(Author)> 2">
  141.         <b>Authors: </b>
  142.         <xsl:for-each select="Author">
  143.           <xsl:choose>
  144.             <xsl:when test="not(position() = last())">
  145.               <xsl:value-of select="."/>
  146.               <xsl:text>, </xsl:text>
  147.             </xsl:when>
  148.             <xsl:otherwise>
  149.               <xsl:text>and </xsl:text>
  150.               <xsl:value-of select="."/>
  151.             </xsl:otherwise>
  152.           </xsl:choose>
  153.         </xsl:for-each>
  154.       </xsl:when>
  155.       <xsl:when test="count(Author) = 2">
  156.         <b>Authors: </b>
  157.         <xsl:value-of select="Author[1]"/>
  158.         <xsl:text> and </xsl:text>
  159.         <xsl:value-of select="Author[2]"/>
  160.       </xsl:when>
  161.       <xsl:otherwise>
  162.         <b>Author: </b>
  163.         <xsl:value-of select="Author"/>
  164.       </xsl:otherwise>
  165.     </xsl:choose>
  166.   </xsl:template>
  167.  
  168.   <xsl:template name="BuyButton">
  169.     <xsl:param name="Asin"/>
  170.     <xsl:element name="a">
  171.       <xsl:attribute name="href" xml:space="default">http://www.amazon.com/o/dt/assoc/handle-buy-box?asin=<xsl:value-of select="$Asin"/>&tag_value=associates_tag&dev-tag-value=D24H52G74BUDRY&submit.add-to-cart=true</xsl:attribute>
  172.       <xsl:attribute name="target" xml:space="default">_blank</xsl:attribute>
  173.       <xsl:text>Buy from Amazon.com</xsl:text>
  174.     </xsl:element>
  175.   </xsl:template>
  176.  
  177.   <xsl:template match="AvgCustomerRating">
  178.     <tr>
  179.       <td colspan="2">
  180.         <b>Average customer rating: </b>
  181.         <xsl:call-template name="Stars">
  182.           <xsl:with-param name="average" select="."/>
  183.         </xsl:call-template>
  184.       </td>
  185.     </tr>
  186.   </xsl:template>
  187.  
  188.   <xsl:template match="CustomerReview">
  189.     <tr>
  190.       <td colspan="2">
  191.         <xsl:call-template name="Stars">
  192.           <xsl:with-param name="average" select="Rating"/>
  193.         </xsl:call-template>
  194.         <xsl:text> </xsl:text>
  195.         <b><xsl:value-of select="Summary"/></b>
  196.         <br />
  197.         <p><xsl:value-of select="Comment"/></p>
  198.       </td>
  199.     </tr>
  200.   </xsl:template>
  201.  
  202.   <xsl:template name="Stars">
  203.     <xsl:param name="average" select="5"/>
  204.     <xsl:choose>
  205.       <xsl:when test="$average > 4.75">
  206.         <img src="http://g-images.amazon.com/images/G/01/detail/stars-5-0.gif"/>
  207.       </xsl:when>
  208.       <xsl:when test="$average > 4.25">
  209.         <img src="http://g-images.amazon.com/images/G/01/detail/stars-4-5.gif"/>
  210.       </xsl:when>
  211.       <xsl:when test="$average > 3.75">
  212.         <img src="http://g-images.amazon.com/images/G/01/detail/stars-4-0.gif"/>
  213.       </xsl:when>
  214.       <xsl:when test="$average > 3.25">
  215.         <img src="http://g-images.amazon.com/images/G/01/detail/stars-3-5.gif"/>
  216.       </xsl:when>
  217.       <xsl:when test="$average > 2.75">
  218.         <img src="http://g-images.amazon.com/images/G/01/detail/stars-3-0.gif"/>
  219.       </xsl:when>
  220.       <xsl:when test="$average > 2.25">
  221.         <img src="http://g-images.amazon.com/images/G/01/detail/stars-2-5.gif"/>
  222.       </xsl:when>
  223.       <xsl:when test="$average > 1.75">
  224.         <img src="http://g-images.amazon.com/images/G/01/detail/stars-2-0.gif"/>
  225.       </xsl:when>
  226.       <xsl:when test="$average > 1.25">
  227.         <img src="http://g-images.amazon.com/images/G/01/detail/stars-1-5.gif"/>
  228.       </xsl:when>
  229.       <xsl:when test="$average > .75">
  230.         <img src="http://g-images.amazon.com/images/G/01/detail/stars-1-0.gif"/>
  231.       </xsl:when>
  232.       <xsl:when test="$average > .25">
  233.         <img src="http://g-images.amazon.com/images/G/01/detail/stars-0-5.gif"/>
  234.       </xsl:when>
  235.       <xsl:otherwise>
  236.         <img src="http://g-images.amazon.com/images/G/01/detail/stars-0-0.gif"/>
  237.       </xsl:otherwise>
  238.     </xsl:choose>
  239.   </xsl:template>
  240.  
  241. </xsl:stylesheet>
  242.