<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output method="html"
            encoding="ISO-8859-1"/>

<!-- Created by Johan Lindgren (TT Sweden) to show all components of SportsML files.
     Base of script from the book XSLT - Mastering XML transformations by Doug Tidwell
     -->


<!--      MAIN TEMPLATE   -->
<xsl:template match="/">
<html>
 <head>
  <title><xsl:value-of select="ContentItem/sports-content/sports-title"/></title>
  <link rel="stylesheet" type="text/css" href="sportsml.css"/>
 </head>
 <body>
  <table width="100%" bgcolor="#FF5100" cellspacing="2" border="1">
   <tr bgcolor="#FF5100">
     <td colspan="2"><b>Root of document: </b></td>
   </tr>
   <xsl:for-each select="*|comment()|processing-instruction()|text()">
    <tr bgcolor="#FF5100">
      <td width="5%"> </td>
      <td><xsl:apply-templates select="."/></td>
    </tr>
   </xsl:for-each>
  </table>
 </body>
</html>
</xsl:template>
<!-- End main template -->


<!-- Produce output of all comments -->
<xsl:template match="comment()">
  <table width="100%" cellspacing="2">
   <tr>
     <td bgcolor="#CCCCFF">Comment: 
      <xsl:value-of select="."/>
     </td>
   </tr>
  </table>
</xsl:template>

<!-- Template to produce output of all processing-instructions -->
<xsl:template match="processing-instruction()">
  <table width="100%" cellspacing="2">
   <tr>
     <td  bgcolor="#99FF99">Processing instruction: 
       <xsl:text>&lt;</xsl:text>
       <xsl:value-of select="name()"/>
       <xsl:text>&gt;</xsl:text>
       <br/>
       <xsl:value-of select="."/>
     </td>
   </tr>
  </table>
</xsl:template>

<!-- template to handle text nodes -->
<xsl:template match="text()">
  <xsl:if test="string-length(normalize-space(.))">
   <tr>
     <td bgcolor="#C0C0C0" width="10%">   </td>
     <td  bgcolor="#FFCC99">Text: </td>
     <td bgcolor="#FFFFFF">
      <xsl:value-of select="."/>
     </td>
   </tr>
  </xsl:if>
</xsl:template>

<!-- template to handle the rest -->
<xsl:template match="*">
  <table width="100%" cellspacing="2" border="1">
   <xsl:choose>
    <xsl:when test="count(@*) &gt; 0">
     <tr>
       <td  colspan="3" bgcolor="#C0C0C0">Element: 
       <xsl:text>&lt;</xsl:text>
       <b><xsl:value-of select="name()"/></b>
       <xsl:text>&gt;</xsl:text>
        <table class="smalltable" width="100%" cellspacing="2" border="0">
         <tr>
          <td bgcolor="#C0C0C0" width="10%">   </td>
          <td  bgcolor="#FFFF99" width="20%"><b>ATTRIBUTE NAME</b></td>
          <td  bgcolor="#FFFF99"><b>ATTRIBUTE VALUE</b></td>
         </tr>
         <xsl:for-each select="@*">
          <tr>
           <td bgcolor="#C0C0C0" width="10%">   </td>
           <td  bgcolor="#FFFF99" width="20%">
             <xsl:value-of select="name()"/>
           </td>
           <td bgcolor="#FFFFFF">
              <b><xsl:value-of select="."/></b>
            </td>
           </tr>
          </xsl:for-each>
        </table>
       </td>
     </tr>
    </xsl:when>
    <xsl:otherwise>
     <tr>
       <td colspan="3" bgcolor="#C0C0C0">Element: 
       <xsl:text>&lt;</xsl:text>
       <b><xsl:value-of select="name()"/></b>
       <xsl:text>&gt;</xsl:text>
       </td>
     </tr>
    </xsl:otherwise>
   </xsl:choose>

   <xsl:for-each select="*|comment()|processing-instruction()|text()">
    <tr bgcolor="#C0C0C0">
      <td width="10%"> </td>
      <td><xsl:apply-templates select="."/></td>
    </tr>
   </xsl:for-each>
  </table>
</xsl:template>




</xsl:stylesheet>