本程序中利用asp代码生成的日志信息存储到xml文件中,然后由xslt格式化输出

该程序共分三个部分:
1.   生成日志的asp程序

代码见以前的一篇文章:


2.   由 上面的 程序 生成的日志文件(.xml)

 


<? 
  xml version="1.0" encoding="gb2312" 
  ?> 
  
 
  <? 
  xml-stylesheet type='text/xsl' href='logInfo.xsl' 
  ?> 
  
 
  < 
  syslog 
  > 
  
 
  < 
  log 
  > 
  
 
  < 
  username 
  > 
  塞北的雪 
  </ 
  username 
  > 
  
 
  < 
  operate 
  > 
  登录 
  </ 
  operate 
  > 
  
 
  < 
  userip 
  > 
  192.168.22.205 
  </ 
  userip 
  > 
  
 
  < 
  opdate 
  > 
  2006-2-15 8:21:27 
  </ 
  opdate 
  > 
  
 
  </ 
  log 
  > 
  
 
  < 
  log 
  > 
  
 
  < 
  username 
  > 
  塞北的雪 
  </ 
  username 
  > 
  
 
  < 
  operate 
  > 
  删除用户(delete from sys_user where user_id='northsnow') 
  </ 
  operate 
  > 
  
 
  < 
  userip 
  > 
  192.168.22.206 
  </ 
  userip 
  > 
  
 
  < 
  opdate 
  > 
  2006-2-15 9:03:21 
  </ 
  opdate 
  > 
  
 
  </ 
  log 
  > 
  
 
  < 
  log 
  > 
  
 
  < 
  username 
  > 
  塞北的雪 
  </ 
  username 
  > 
  
 
  < 
  operate 
  > 
  注销 
  </ 
  operate 
  > 
  
 
  < 
  userip 
  > 
  192.168.22.205 
  </ 
  userip 
  > 
  
 
  < 
  opdate 
  > 
  2006-2-15 9:11:18 
  </ 
  opdate 
  > 
  
 
  </ 
  log 
  > 
  
 
  </ 
  syslog 
  >

3 .   格式化xml文件输出的 xsl文件

 

<?   xml versinotallow="1.0" 
  ?> 
  
   < 
  xsl:stylesheet  
  version 
  ="1.0" 
   xmlns:xsl 
  ="http://www.w3.org/1999/XSL/Transform" 
    xmlns:msxsl 
  ="urn:schemas-microsoft-com:xslt" 
   xmlns:user 
  ="http://www.cccar.com.cn/" 
   
exclude-result-prefixes   ="msxsl user" 
  > 
  

   <!-- 
   localized strings  
  --> 
  
   < 
  xsl:variable  
  name 
  ='ColumnHeader_UserName'>用户</xsl:variable>
   <xsl:variable name 
  ='ColumnHeader_Time'>时间</xsl:variable>
   <xsl:variable name 
  ='ColumnHeader_Operate'>操作</xsl:variable>
   <xsl:variable name 
  ='ColumnHeader_Address'>IP地址</xsl:variable>

   <!-- variables -- 
  > 
  
   < 
  xsl:variable  
  name 
  ='TableStyle'>background-color:#DAE6D8;font-family:Simsun,  
  Verdana; font-size:75%; text-align:left; vertical-align:top</xsl:variable 
  > 
  
   < 
  xsl:variable  
  name 
  ='HeaderStyle'>background:a0b0a8;color:#000000;border-bottom:1  
  solid black;border-top:1 solid black</xsl:variable 
  > 
  
   < 
  msxsl:script  
  language 
  ="javascript" 
   implements-prefix 
  ="user" 
  > 
   
   function xmlDateTime(nodelist) { 
           return Date.parse(nodelist.replace(/-/g,"/")); 
        } 
    </ 
  msxsl:script 
  > 
   
   < 
  xsl:output  
  omit-xml-declaration 
  ="yes" 
  /> 
   
   < 
  xsl:template  
  match 
  ="syslog" 
  > 
  

       < 
  html 
  > 
  
       < 
  head 
  > 
  
           < 
  title 
  > 
  
            日志查看
           </ 
  title 
  > 
  
       </ 
  head 
  > 
  

       < 
  body  
  style 
  ='margin:10;background-color:#DAE6D8'>
           <div align 
  ="center" 
  > 
  
           < 
  table     
  style 
  ="{$TableStyle}" 
   width 
  ="100%" 
   align 
  ="center" 
   cellspacing 
  ='0'>
          
               <thead 
  > 
  
                   < 
  tr  
  height 
  ="23" 
  > 
  
                    
                       < 
  th  
  width 
  ="15%" 
   style 
  ="{$HeaderStyle}" 
  > 
  
                           < 
  xsl:value-of  
  select 
  ="$ColumnHeader_UserName" 
  /> 
  
                       </ 
  th 
  > 
  
                       < 
  th  
  width 
  ="20%" 
   style 
  ="{$HeaderStyle}" 
  > 
  
                           < 
  xsl:value-of  
  select 
  ="$ColumnHeader_Time" 
  /> 
  
                       </ 
  th 
  > 
  
                       < 
  th  
  width 
  ="50%" 
   style 
  ="{$HeaderStyle}" 
  > 
  
                           < 
  xsl:value-of  
  select 
  ="$ColumnHeader_Operate" 
  /> 
  
                       </ 
  th 
  > 
  
                       < 
  th  
  width 
  ="15%" 
   style 
  ="{$HeaderStyle}" 
  > 
  
                           < 
  xsl:value-of  
  select 
  ="$ColumnHeader_Address" 
  /> 
  
                       </ 
  th 
  > 
  
                   </ 
  tr 
  > 
  
               </ 
  thead 
  > 
  
            
               < 
  tbody  
  style 
  ='vertical-align:top'>
                    <tr  
  >< 
  td  
  colspan 
  ="4" 
   height 
  ="5" 
  ></ 
  td 
  ></ 
  tr 
  > 
    
                    < 
  xsl:for-each  
  select 
  ="log" 
  > 
  
                       < 
  xsl:sort  
  order 
  ='ascending'   
  select 
  ="user:xmlDateTime(string(opdate))" 
   data-type 
  ="number" 
  /> 
  
                     
                      < 
  tr  
  height 
  ="23" 
  > 
   
                    
                        < 
  td  
  valign 
  ="bottom" 
  >< 
  xsl:value-of  
  select 
  ="username" 
  /></ 
  td 
  > 
  
                        < 
  td  
  valign 
  ="bottom" 
    
  >< 
  xsl:value-of  
  select 
  ="opdate" 
  /></ 
  td 
  > 
  
                        < 
  td  
  valign 
  ="bottom" 
    
  >< 
  xsl:value-of  
  select 
  ="operate" 
  /></ 
  td 
  > 
  
                        < 
  td  
  valign 
  ="bottom" 
    
  >< 
  xsl:value-of  
  select 
  ="userip" 
  /></ 
  td 
  > 
    
                     </ 
  tr 
  > 
  
                     < 
  tr  
  bgcolor 
  ="#999999" 
  >< 
  td  
  colspan 
  ="4" 
   height 
  ="1" 
  ></ 
  td 
  ></ 
  tr 
  > 
    
                   </ 
  xsl:for-each 
  > 
  
                
                   < 
  tr 
  >< 
  td  
  colspan 
  ="4" 
   align 
  ="right" 
  > 
  合计: 
  < 
  xsl:value-of  
  select 
  ="count(log)" 
  /> 
   条  
  </ 
  td 
  ></ 
  tr 
  > 
      
               </ 
  tbody 
  > 
  
           </ 
  table 
  > 
  
   </ 
  div 
  > 
  
       </ 
  body 
  > 
  
       </ 
  html 
  > 
  

   </ 
  xsl:template 
  > 
  
   </ 
  xsl:stylesheet 
  >