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 / profile2html.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  8.3 KB  |  277 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. <xsl:stylesheet version="1.0"
  19.  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  20.  xmlns:profile="http://apache.org/cocoon/profiler/1.0">
  21.  
  22.   <xsl:param name="sort"/>
  23.   <xsl:param name="key"/>
  24.   <xsl:param name="result"/>
  25.   <xsl:param name="component"/>
  26.  
  27.   <xsl:template match="/">
  28.     <html>
  29.       <head>
  30.         <title>Cocoon2 profile information [<xsl:value-of select="profile:profilerinfo/@date"/>]</title>
  31.       </head>
  32.       <body>
  33.         <xsl:choose>
  34.           <xsl:when test="$component!=''">
  35.             <xsl:apply-templates
  36.               select="profile:profilerinfo/profile:pipeline/profile:result/profile:component[@index=$component]"
  37.               mode="fragment"/>
  38.           </xsl:when>
  39.           <xsl:when test="$result!=''">
  40.             <xsl:apply-templates select="profile:profilerinfo/profile:pipeline/profile:result" mode="result"/>
  41.           </xsl:when>
  42.           <xsl:otherwise>
  43.             <xsl:apply-templates select="profile:profilerinfo" mode="pipelines"/>
  44.           </xsl:otherwise>
  45.         </xsl:choose>
  46.       </body>
  47.     </html>
  48.   </xsl:template>
  49.  
  50.   <xsl:template match="profile:profilerinfo" mode="pipelines">
  51.     Sort results by <a href="?sort=uri">uri</a>,
  52.     <a href="?sort=count">count</a>, <a href="?sort=time">time</a>.
  53.  
  54.     <table noshade="noshade" border="0" cellspacing="1" cellpadding="0">
  55.       <xsl:choose>
  56.         <xsl:when test="$sort = 'uri'">
  57.           <xsl:apply-templates select="profile:pipeline">
  58.             <xsl:sort select="@uri"/>
  59.           </xsl:apply-templates>
  60.         </xsl:when>
  61.         <xsl:when test="$sort = 'time'">
  62.           <xsl:apply-templates select="profile:pipeline">
  63.             <xsl:sort select="@time" data-type="number"/>
  64.           </xsl:apply-templates>
  65.         </xsl:when>
  66.         <xsl:when test="$sort = 'count'">
  67.           <xsl:apply-templates select="profile:pipeline">
  68.             <xsl:sort select="@count" data-type="number"/>
  69.           </xsl:apply-templates>
  70.         </xsl:when>
  71.         <xsl:otherwise>
  72.           <xsl:apply-templates/>
  73.         </xsl:otherwise>
  74.       </xsl:choose>
  75.     </table>
  76.   </xsl:template>
  77.  
  78.   <xsl:template match="profile:pipeline">
  79.     <xsl:if test="position() mod 5 = 1">
  80.       <tr bgcolor="#FFC0C0">
  81.        <th></th>
  82.        <th>Component</th>
  83.        <th>Average</th>
  84.        <th colspan="10">Last Results</th>
  85.       </tr>
  86.     </xsl:if>
  87.     <tr bgcolor="#C0C0FF">
  88.      <td colspan="3">
  89.        <font face="verdana"><strong><xsl:value-of select="@uri"/></strong></font>
  90.        (<xsl:value-of select="@count"/> results,
  91.        total time: <xsl:value-of select="@processingTime"/>,
  92.        average time: <xsl:value-of select="profile:average/@time"/>)
  93.      </td>
  94.      <xsl:for-each select="profile:result">
  95.       <td>
  96.        <a href="?key={../@key}&result={@index}">
  97.         <xsl:value-of select="@index"/>
  98.        </a>
  99.       </td>
  100.      </xsl:for-each>
  101.     </tr>
  102.  
  103.     <xsl:for-each select="profile:average/profile:component">
  104.       <xsl:variable name="bgcolor">
  105.        <xsl:if test="position() mod 2 = 0">#D0D0D0</xsl:if>
  106.        <xsl:if test="position() mod 2 = 1">#E0E0E0</xsl:if>
  107.       </xsl:variable>
  108.       <tr bgcolor="{$bgcolor}">
  109.  
  110.        <xsl:variable name="pos" select="position()"/>
  111.        <td>
  112.         <xsl:value-of select="$pos"/>
  113.        </td>
  114.        <td>
  115.          <xsl:value-of select="@role"/>
  116.          <xsl:text> </xsl:text>
  117.          <xsl:if test="@source">
  118.            <i>src=</i><xsl:value-of select="@source"/>
  119.          </xsl:if>
  120.        </td>
  121.  
  122.        <xsl:for-each select="../../profile:average/profile:component[position()=$pos]">
  123.         <th>
  124.          <xsl:value-of select="@time"/>
  125.         </th>
  126.        </xsl:for-each>
  127.  
  128.        <xsl:for-each select="../../profile:result/profile:component[position()=$pos]">
  129.         <td>
  130.           <xsl:value-of select="@time"/>
  131.         </td>
  132.        </xsl:for-each>
  133.  
  134.       </tr>
  135.     </xsl:for-each>
  136.  
  137.        <xsl:variable name="pos" select="count(profile:average/profile:component)"/>
  138.       <tr>
  139.        <td>
  140.         <xsl:value-of select="$pos+1"/>
  141.        </td>
  142.        <td>
  143.         TOTAL
  144.        </td>
  145.  
  146.         <th>
  147.          <xsl:value-of select="profile:average/@time"/>
  148.         </th>
  149.  
  150.        <xsl:for-each select="profile:result">
  151.         <td>
  152.          <xsl:value-of select="@time"/>
  153.         </td>
  154.        </xsl:for-each>
  155.  
  156.       </tr>
  157.   </xsl:template>
  158.  
  159.   <xsl:template match="profile:result" mode="result">
  160.     <h1><xsl:value-of select="profile:environmentinfo/profile:uri"/></h1>
  161.     <table>
  162.       <tr bgcolor="#FFC0C0">
  163.         <th></th>
  164.         <th>Component</th>
  165.         <th colspan="3">Results</th>
  166.       </tr>
  167.       <tr bgcolor="#C0C0FF">
  168.         <td colspan="2">
  169.           <font face="verdana"><strong><xsl:value-of select="profile:environmentinfo/profile:uri"/></strong></font>
  170.         </td>
  171.         <td>Total Time</td>
  172.         <td>Setup Time</td>
  173.         <td>Processing Time</td>
  174.         <td/>
  175.       </tr>
  176.  
  177.       <xsl:for-each select="profile:component">
  178.         <xsl:variable name="bgcolor">
  179.           <xsl:if test="position() mod 2 = 0">#D0D0D0</xsl:if>
  180.           <xsl:if test="position() mod 2 = 1">#E0E0E0</xsl:if>
  181.         </xsl:variable>
  182.         <tr bgcolor="{$bgcolor}">
  183.  
  184.           <xsl:variable name="pos" select="position()"/>
  185.           <td>
  186.             <xsl:value-of select="$pos"/>
  187.           </td>
  188.           <td>
  189.             <xsl:value-of select="@role"/>
  190.             <xsl:text> </xsl:text>
  191.             <xsl:if test="@source">
  192.               <i>src=</i><xsl:value-of select="@source"/>
  193.             </xsl:if>
  194.           </td>
  195.  
  196.           <td>
  197.             <xsl:value-of select="@time"/>
  198.           </td>
  199.  
  200.           <td>
  201.             <xsl:value-of select="@setup"/>
  202.           </td>
  203.  
  204.           <td>
  205.             <xsl:value-of select="@processing"/>
  206.           </td>
  207.  
  208.           <td>
  209.             <xsl:if test="position() != last()">
  210.               <a href="profile.xml?key={$key}&result={$result}&component={@index}&fragmentonly=true">[XML]</a>
  211.                 
  212.               <a href="profile.xml?key={$key}&result={$result}&component={@index}&fragmentonly=true&cocoon-view=pretty-content">[XML as HTML]</a>
  213.             </xsl:if>
  214.           </td>
  215.         </tr>
  216.       </xsl:for-each>
  217.     </table>
  218.     <xsl:apply-templates select="profile:environmentinfo"/>
  219.   </xsl:template>
  220.  
  221.   <xsl:template match="profile:environmentinfo">
  222.    <xsl:apply-templates select="profile:request-parameters"/>
  223.    <xsl:apply-templates select="profile:session-attributes"/>
  224.   </xsl:template>
  225.  
  226.   <xsl:template match="profile:request-parameters">
  227.     <table>
  228.       <tr bgcolor="#C0C0FF">
  229.        <th colspan="2">
  230.         Request parameters
  231.        </th>
  232.       </tr>
  233.       <tr bgcolor="#FFC0C0">
  234.         <th>Name</th>
  235.         <th>Value</th>
  236.       </tr>
  237.       <xsl:for-each select="profile:parameter">
  238.         <xsl:variable name="bgcolor">
  239.           <xsl:if test="position() mod 2 = 0">#D0D0D0</xsl:if>
  240.           <xsl:if test="position() mod 2 = 1">#E0E0E0</xsl:if>
  241.         </xsl:variable>
  242.  
  243.         <tr bgcolor="{$bgcolor}">
  244.           <td><xsl:value-of select="@name"/></td>
  245.           <td><xsl:value-of select="@value"/></td>
  246.         </tr>
  247.       </xsl:for-each>
  248.     </table>
  249.   </xsl:template>
  250.  
  251.   <xsl:template match="profile:session-attributes">
  252.     <table>
  253.       <tr bgcolor="#C0C0FF">
  254.        <th colspan="2">
  255.         Session attributes
  256.        </th>
  257.       </tr>
  258.       <tr bgcolor="#FFC0C0">
  259.         <th>Name</th>
  260.         <th>Value</th>
  261.       </tr>
  262.       <xsl:for-each select="profile:attribute">
  263.         <xsl:variable name="bgcolor">
  264.           <xsl:if test="position() mod 2 = 0">#D0D0D0</xsl:if>
  265.           <xsl:if test="position() mod 2 = 1">#E0E0E0</xsl:if>
  266.         </xsl:variable>
  267.  
  268.         <tr bgcolor="{$bgcolor}">
  269.           <td><xsl:value-of select="@name"/></td>
  270.           <td><xsl:value-of select="@value"/></td>
  271.         </tr>
  272.       </xsl:for-each>
  273.     </table>
  274.   </xsl:template>
  275.  
  276. </xsl:stylesheet>
  277.