home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / status2html.xslt < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  3.2 KB  |  96 lines

  1. <?xml version="1.0"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17.  
  18. <!--+
  19.     | Converts output of the StatusGenerator into HTML page
  20.     | 
  21.     | CVS $Id: status2html.xslt,v 1.8 2004/03/06 02:25:41 antonio Exp $
  22.     +-->
  23.  
  24. <xsl:stylesheet version="1.0"
  25.                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  26.                 xmlns:status="http://apache.org/cocoon/status/2.0">
  27.  
  28.   <xsl:param name="contextPath"/>
  29.  
  30.   <xsl:template match="status:statusinfo">
  31.     <html>
  32.       <head>
  33.         <title>Cocoon Status [<xsl:value-of select="@status:host"/>]</title>
  34.         <link href="{$contextPath}/styles/main.css" type="text/css" rel="stylesheet"/>
  35.         <script src="{$contextPath}/scripts/main.js" type="text/javascript"/>
  36.       </head>
  37.  
  38.       <body>
  39.         <h1><xsl:value-of select="@status:host"/> - <xsl:value-of select="@status:date"/></h1>
  40.         <xsl:apply-templates/>
  41.       </body>
  42.     </html>
  43.   </xsl:template>
  44.  
  45.   <xsl:template match="status:group">
  46.     <h2><xsl:value-of select="@status:name"/></h2>
  47.     <ul><xsl:apply-templates select="status:value"/></ul>
  48.     <xsl:apply-templates select="status:group"/>
  49.   </xsl:template>
  50.  
  51.   <xsl:template match="status:value">
  52.     <li>
  53.       <span class="description"><xsl:value-of select="@status:name"/><xsl:text>: </xsl:text></span>
  54.       <xsl:choose>
  55.         <xsl:when test="contains(@status:name,'free') or contains(@status:name,'total')">
  56.           <xsl:call-template name="suffix">
  57.             <xsl:with-param name="bytes" select="number(.)"/>
  58.           </xsl:call-template>
  59.         </xsl:when>      
  60.         <xsl:when test="count(status:line) <= 1">
  61.           <xsl:value-of select="status:line"/>
  62.         </xsl:when>
  63.         <xsl:otherwise>
  64.           <span class="switch" id="{generate-id(.)}-switch" onclick="toggle('{generate-id(.)}')">[show]</span>
  65.           <ul id="{generate-id(.)}" style="display: none">
  66.              <xsl:apply-templates />
  67.           </ul>
  68.         </xsl:otherwise>
  69.       </xsl:choose>
  70.     </li>
  71.   </xsl:template>
  72.  
  73.   <xsl:template match="status:line">
  74.     <li><xsl:value-of select="."/></li>
  75.   </xsl:template>
  76.  
  77.   <xsl:template name="suffix">
  78.     <xsl:param name="bytes"/>
  79.     <xsl:choose>
  80.       <!-- More than 4 MB (=4194304) -->
  81.       <xsl:when test="$bytes >= 4194304">
  82.         <xsl:value-of select="round($bytes div 10485.76) div 100"/> MB
  83.       </xsl:when>
  84.       <!-- More than 4 KB (=4096) -->
  85.       <xsl:when test="$bytes > 4096">
  86.         <xsl:value-of select="round($bytes div 10.24) div 100"/> KB
  87.       </xsl:when>
  88.       <!-- Less -->
  89.       <xsl:otherwise>
  90.         <xsl:value-of select="$bytes"/> B
  91.       </xsl:otherwise>
  92.     </xsl:choose>
  93.   </xsl:template>
  94.   
  95. </xsl:stylesheet>
  96.