home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 October / enter-2005-10.iso / files / bzflag-2.0.4.exe / doc / doc.xsl < prev    next >
Encoding:
Text File  |  2005-01-17  |  3.6 KB  |  107 lines

  1. <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  2. <!--To use, add
  3.     <?xml-stylesheet type="text/xsl" href="../doc.xsl"?>
  4.     To the top of any xml document, using the correct relative path.
  5. -->
  6. <xsl:template match="book">
  7.     <html>
  8.         <head>
  9.             <title>BZFlag - <xsl:value-of select="bookinfo/title"/></title>
  10.             <style type="text/css">
  11.                 a { font-size: 110%; text-decoration:none; display: block; color:#0000FF; background-color:#DAE2F6; }
  12.                 a:link.selected { display: block; color:#000000; background-color:#BED0EA; }
  13.                 a:visit.selected { display: block; color:#000000; background-color:#BED0EA; }
  14.                 a:hover.selected { display: block; color:#000000; background-color: #BED0EA; }
  15.                 a:link.unselected { display: block; color:#0000FF; background-color:#9FB5E0; }
  16.                 a:visit.unselected { display: block; color:#0000FF; background-color:#7090D0; }
  17.                 a:hover.unselected { display: block; color:#000000; background-color: #BED0EA; }
  18.             </style>
  19.  
  20.             <script language="JavaScript">
  21.                 var curDiv = "<xsl:value-of select="chapter[1]/@id"/>";
  22.                 function switchDiv( divName )
  23.                 {
  24.                     var el = document.getElementById( curDiv );
  25.                     el.style.display = "none";
  26.                     el = document.getElementById( curDiv + "_ctrl" );
  27.                     el.className = "unselected";
  28.                     el = document.getElementById( divName );
  29.                     el.style.display = "block";
  30.                     el = document.getElementById( divName + "_ctrl" );
  31.                     el.className = "selected";
  32.                     curDiv = divName;
  33.                 }
  34.             </script>
  35.         </head>
  36.         <body bgcolor="#E0E0FF">
  37.         <xsl:apply-templates select="bookinfo"/>
  38.         <xsl:call-template name="ctrl"/>
  39.         <xsl:call-template name="chapters"/>
  40.         <script language="JavaScript">
  41.             switchDiv("<xsl:value-of select="chapter[1]/@id"/>");
  42.         </script>
  43.         </body>
  44.     </html>
  45.  
  46. </xsl:template>
  47.  
  48. <xsl:template match="bookinfo">
  49.     <h1><xsl:value-of select="title"/></h1>
  50.     <h4>published: <xsl:value-of select="pubdate"/></h4>
  51.     <xsl:apply-templates select="abstract"/>
  52. </xsl:template>
  53.  
  54. <xsl:template match="abstract">
  55.     <hr/>
  56.     <xsl:for-each select="para">
  57.         <p><xsl:value-of select="."/></p>
  58.     </xsl:for-each>
  59.     <hr/>
  60. </xsl:template>
  61.  
  62. <xsl:template name="ctrl">
  63.     <xsl:variable name="chapWidth" select="100.0 div count(chapter)"/>
  64.     <table border="1" width="100%">
  65.         <tr>
  66.         <xsl:for-each select="chapter">
  67.             <xsl:element name="td">
  68.                 <xsl:attribute name="width"><xsl:value-of select="$chapWidth"/>%</xsl:attribute>
  69.                 <xsl:variable name="divid"><xsl:value-of select="@id"/></xsl:variable>
  70.                 <xsl:element name="a">
  71.                     <xsl:attribute name="href">javascript:switchDiv("<xsl:value-of select="$divid"/>")</xsl:attribute>
  72.                     <xsl:attribute name="class">unselected</xsl:attribute>
  73.                     <xsl:attribute name="id"><xsl:value-of select="@id"/>_ctrl</xsl:attribute>
  74.                     <xsl:value-of select="title"/>
  75.                 </xsl:element>
  76.             </xsl:element>
  77.         </xsl:for-each>
  78.         </tr>
  79.     </table>
  80. </xsl:template>
  81.  
  82. <xsl:template name="chapters">
  83.     <xsl:for-each select="chapter">
  84.         <xsl:element name="div">
  85.             <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
  86.             <xsl:attribute name="style">display:none;</xsl:attribute>
  87.             <table width="100%">
  88.                 <xsl:for-each select="para|screen">
  89.                     <xsl:if test='name(.)="para"'>
  90.                         <tr><td>
  91.                             <xsl:value-of select="."/>
  92.                         </td></tr>
  93.                     </xsl:if>
  94.                     <xsl:if test='name(.)="screen"'>
  95.                         <tr><td><pre>
  96.                             <xsl:value-of select="."/>
  97.                         </pre></td></tr>
  98.                     </xsl:if>
  99.                 </xsl:for-each>
  100.             </table>
  101.         </xsl:element>
  102.     </xsl:for-each>
  103. </xsl:template>
  104.  
  105.  
  106. </xsl:transform>
  107.