<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
   <xsl:apply-templates />
</xsl:template>
<xsl:template match="booklist" xml:space="preserve">
<html>
<head>
   <title>XML XSLT Presentation Example</title>

   <style>
   .booklist {
      display: block;
      margin-left: auto;
      margin-right: auto;
      text-align: center;
   }
   .book {
      display: block;
      border: 2px red solid;
      margin: 12pt auto 12pt auto;
      padding: 12pt;
      font-family: verdana;
      font-size: 8pt;
      text-align: left;
      width: 80%;
   }
   .topleft {
      display: block;
      position: relative;
      float: left;
      width: 70%;
   }
   .topright {
      display: block;
      position: relative;
      float: right;
      width: 30%;
   }
   .spacer {
      display: block;
      clear: all;
   }
   .description {
      display: block;
      float: center;
      margin-top: 12pt;
      padding: 12pt;
      border: 2px #0000cc inset;
      background-color: #f0f0ff;
   }
   .booktitle {
      display: block;
      margin-top: 12pt;
      font-size: 3em;
      font-weight: bold;
      font-style: italic;
   }
   .publisher {
      display: block;
      margin-top: 6pt;
      font-size: 2em;
      font-style: italic;
   }
   .byline {
      display: block;
      text-align: right;
      margin-top: 12pt;
      padding-right: 12pt;
      font-size: 1.25em;
      text-decoration: underline;
   }
   .author {
      display: block;
      text-align: right;
      margin-top: 6pt;
      padding-right: 12pt;
   }
   .names {
      display: inline;
      font-size: 1.5em;
      font-weight: bold;
   }
   .book_image {
      display: block;
      text-align: right;
      padding: 12pt;
   }
   .block_italic {
      display: block;
      margin-top: 18pt;
      font-size: 1.25em;
      line-height: 1.5em;
      font: italic;
   }
   </style>
</head>
<body>
   <xsl:call-template name="book" />
</body>
</html>
</xsl:template>


<xsl:template name="book" xml:space="preserve">
   <xsl:for-each select="/booklist/book">
   <div class="booklist">
      <div class="book">
         <div class="topleft">
            <div class="booktitle">
               <xsl:value-of select="booktitle" />
            </div>
            <div class="publisher">
               <![CDATA[Publisher: ]]><xsl:value-of select="publisher" />
            </div>
            <div class="block_italic">
               <![CDATA[Publish Date: ]]><xsl:value-of select="substring(pub_date,1,4)" /><![CDATA[-]]><xsl:value-of select="substring(pub_date,5,2)" /><![CDATA[-]]><xsl:value-of select="substring(pub_date,7,2)" /><br />
               <![CDATA[ISBN NO: ]]><xsl:value-of select="isbn_no" /><br />
               <![CDATA[CAD PRICE: $]]><xsl:value-of select="format-number(price,'#.00')" />
            </div>
         </div>
         <div class="topright">
            <div class="book_image">
               <xsl:element name="img" xml:space="default">
                  <xsl:attribute name="src">
                     <xsl:value-of select="book_image" />
                  </xsl:attribute>
               </xsl:element>
            </div>
            <div class="byline">
            <xsl:choose>
               <xsl:when test="count(author)&gt;1">
                  <![CDATA[Authors]]><br />
               </xsl:when>
               <xsl:otherwise>
                  <![CDATA[Author]]><br />
               </xsl:otherwise>
            </xsl:choose>
            </div>
            <div class="author">
               <xsl:call-template name="DisplayAuthor" />
            </div>
         </div>
         <div class="spacer">
            <![CDATA[ ]]>
         </div>
         <div class="description">
               <xsl:value-of select="description" />
         </div>
      </div>
   </div>
   </xsl:for-each>
</xsl:template>

<xsl:template name="DisplayAuthor" xml:space="preserve">
   <xsl:for-each select="author">
               <div class="names">
                  <xsl:value-of select="first_name" /> <xsl:if test="middle_init!=''"><xsl:value-of select="middle_init" /> </xsl:if><xsl:value-of select="last_name" /><br />
               </div>
   </xsl:for-each>
</xsl:template>
</xsl:stylesheet>


