<?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"/>
 <xsl:template match="/">
  <html>
   <head>
   <title>Some Books From Amazon.com</title>
   </head>
   <body>
   <h1>Some Books From Amazon.com</h1>
   <xsl:apply-templates select="ProductInfo/Details"/>
   <h5>Web page by <a href="http://www.tomw.net.au/">Tom Worthington</a> to demonstrate 
<a href="http://www.tomw.net.au/2002/ws/index.html">Web Services</a> - Comments to: <a
href="mailto:webmaster@tomw.net.au">webmaster@tomw.net.au</a></h5> 
   </body>
  </html>
 </xsl:template>

 <xsl:template match="Details">
  <p>
  <a href="http://www.amazon.com/exec/obidos/ASIN/{Asin}/universalservice"><img src="{ImageUrlMedium}" width="107" height="140" align="left" alt=""/>
  <xsl:value-of select="ProductName"/></a>, 
  <xsl:apply-templates select="Authors" />
  <xsl:text>, </xsl:text> <xsl:value-of select="Manufacturer"/>
  <xsl:text>, </xsl:text> <xsl:value-of select="ReleaseDate"/>
  <xsl:text>.</xsl:text>
  <br clear="all"/>
  </p>
 </xsl:template>

 <xsl:template match="Authors">
  <xsl:text>by </xsl:text>
  <xsl:choose>
  <xsl:when test="count(Author)&gt; 2">
   <xsl:for-each select="Author">
    <xsl:choose>
     <xsl:when test="not(position() = last())">
      <xsl:value-of select="."/>
       <xsl:text>, </xsl:text>
     </xsl:when>
     <xsl:otherwise>
     <xsl:text>and </xsl:text>
       <xsl:value-of select="."/>
     </xsl:otherwise>
        </xsl:choose>
   </xsl:for-each>
  </xsl:when>
  <xsl:when test="count(Author) = 2">
   <xsl:value-of select="Author[1]"/>
    <xsl:text> and </xsl:text>
     <xsl:value-of select="Author[2]"/>
  </xsl:when>
  <xsl:otherwise>
    <xsl:value-of select="Author"/>
  </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
</xsl:stylesheet>