<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:david="http://www.davidbirch2.com">
    <xsl:output method="html" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
        doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
    <!-- template for the root -->
    <xsl:template match="/">
        <html>
             <head>
                <meta http-equiv="Content-Language" content="en-gb"/>
                <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
                <title><xsl:value-of select="/david:QuestionXML/david:Question/david:Title"/> - XML Questioner</title>
            </head>
             <body bgcolor="#003399" text="#FFFFFF" link="#FFFFFF" vlink="#C0C0C0" alink="#FF0000">
                <table border="1" width="100%" bgcolor="#0099CC">
                    <tr>
                        <td width="100%">
                            <h1 align="center"><font color="#FFFFFF" face="Tempus Sans ITC">XML - Questioner</font></h1>
                        </td>
                    </tr>
                </table>
                 <xsl:apply-templates select="david:QuestionXML"/>
             </body>
         </html>                
    </xsl:template>
    <!-- template dealing with every question-->
    <xsl:template match="david:QuestionXML">
        <table border="1" width="100%">
            <tr>
                <td width="10%" valign="top" bgcolor="#006699">
                    <h2 align="center"><font color="#FFFFFF" face="Tempus Sans ITC"><b>Menu</b> </font></h2>
                   <p>
                        <a href="http://validator.w3.org/check?uri=referer"><img
                            src="http://www.w3.org/Icons/valid-xhtml10"
                            alt="Valid XHTML 1.0!" height="31" width="88" /></a>
                    </p>
                </td>
                <td width="50%" valign="top">
                    <xsl:apply-templates select="david:Question | david:Answer"></xsl:apply-templates>
                </td>
            </tr>
        </table>
    </xsl:template>
    <!-- template dealing with the actual question-->
    <xsl:template match="david:Question">
             <div align="center">
                <center>
                    <table border="1" width="90%" cellpadding="8">
                        <tr>
                            <td width="80%">
                                <h1 align="center" style="line-height: 100%"><font face="Tempus Sans ITC">
                                    <xsl:value-of select="david:Title" /></font></h1>
                            </td>
                            <td width="20%">
                                <p /> <h1 align="center" style="line-height: 100%"><font face="Tempus Sans ITC">
                                    <xsl:value-of select="david:AuthorID" /></font></h1></td>
                        </tr>
                        <tr>
                            <td width="200%" colspan="2">
                                <xsl:value-of select="david:Question_Text"/>
                                <xsl:apply-templates select="david:MultiMedia"/>
                            </td>
                        </tr>
                    </table>
                </center>
            </div>
    </xsl:template>
    <!-- template dealing with the MultiMedia-->
     <xsl:template match="david:MultiMedia">
                 <div align="right">
                    <table border="1" width="25%" align="right" cellspacing="0">
                        <tr>
                            <td width="100%" valign="top">
 <xsl:choose>
  <xsl:when test="david:Width and david:Height">
    <img border="0" src="http://{david:URL}" width="{david:Width}" height="{david:Height}" alt="{david:Alt_Text}"/>
  </xsl:when>
  <xsl:otherwise>
    <img border="0" src="http://{david:URL}" alt="{david:Alt_Text}"/>
  </xsl:otherwise>
</xsl:choose>                                                     
                             </td>
                        </tr>
                        <xsl:apply-templates select="david:Caption"/>
                     </table>
                </div>                   
     </xsl:template>
    <!-- template dealing with the Captions-->
    <xsl:template match="david:Caption">
             <tr>
                <td width="100%" valign="top"><xsl:value-of select="."/> - <xsl:value-of select="following-sibling::david:CopyRightText"/></td>
            </tr>
    </xsl:template>
    <!-- template dealing with the answers -->
    <xsl:template match="david:Answer">
                     <div align="center">
    <table border="1" width="80%" cellpadding="5">
        <tr>
            <td width="20%"><font face="Tempus Sans ITC"><a href="http://www.davidbirch2.com/Questions/Questions/Q{david:Link_to}.xml"><xsl:value-of select="david:Answer_ID"/></a></font></td>
            <td width="80%"><font face="Tempus Sans ITC"><a href="http://www.davidbirch2.com/Questions/Questions/Q{david:Link_to}.xml"><xsl:value-of select="david:Title"/></a></font></td>
        </tr>
        <tr>
            <td width="200%" colspan="2"><xsl:value-of select="david:Answer_Text"/>
                <xsl:apply-templates select="david:MultiMedia"/>
            </td>
        </tr>
    </table>
    </div>
</xsl:template>
</xsl:stylesheet>
