formatting.xsl

来自「PERL语言资料 可以用于PERL程序设计」· XSL 代码 · 共 101 行

XSL
101
字号
<?xml version = "1.0"?>

<!-- Fig. 22.37 : formatting.xsl -->

<xsl:stylesheet xmlns:xsl = "http://www.w3.org/TR/WD-xsl">

   <xsl:template match = "*|@*|text()|cdata()|comment()|pi()">
      <xsl:copy><xsl:apply-templates
         select = "*|@*|text()|cdata()|comment()|pi()"/></xsl:copy>
   </xsl:template>

   <xsl:template match = "/">
      <html>
      <xsl:apply-templates select = "*"/>
      </html>
   </xsl:template>

   <xsl:template match = "forum">
      <head>
         <title><xsl:value-of select = "name"/></title>
         <link rel = "stylesheet" type = "text/css"
            href = "../XML/site.css"/>
      </head>

      <body>
         <table width = "100%" cellspacing = "0"
            cellpadding = "2">
            <tr>
               <td class = "forumTitle">
                  <xsl:value-of select = "name"/>
               </td>
            </tr>
         </table>

         <br/>
         <xsl:apply-templates select = "message"/>
         <br/>

         <center>
            <a>
              <xsl:attribute name = "HREF">../cgi-bin/addPost.pl?file=<xsl:value-of select = "@file"/>
              </xsl:attribute>
              Post a Message
            </a>
            <br/>
            <br/>
            <a href = "../cgi-bin/default.pl">Return to Main Page</a>
         </center>

      </body>
   </xsl:template>

   <xsl:template match = "message">
      <table width = "100%" cellspacing = "0"
         cellpadding = "2">
         <tr>

            <td class = "msgTitle">
               <xsl:value-of select = "title"/>
            </td>

         </tr>

         <tr>
            <td class = "msgInfo">
               by
               <em><xsl:value-of select = "user"/></em>
               at
               <span class = "date">
                  <xsl:value-of select = "@timestamp"/>
               </span>
            </td>
         </tr>

         <tr>
            <td class = "msgText">
               <xsl:apply-templates select = "text"/>
            </td>
         </tr>

      </table>
   </xsl:template>

</xsl:stylesheet>

<!-- 
 ************************************************************************** 
 * (C) Copyright 2001 by Deitel & Associates, Inc. and Prentice Hall.     *
 * All Rights Reserved.                                                   *
 *                                                                        *
 * DISCLAIMER: The authors and publisher of this book have used their     *
 * best efforts in preparing the book. These efforts include the          *
 * development, research, and testing of the theories and programs        *
 * to determine their effectiveness. The authors and publisher make       *
 * no warranty of any kind, expressed or implied, with regard to these    *
 * programs or to the documentation contained in these books. The authors *
 * and publisher shall not be liable in any event for incidental or       *
 * consequential damages in connection with, or arising out of, the       *
 * furnishing, performance, or use of these programs.                     *
 **************************************************************************
-->

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?