bruno       2003/03/21 09:30:37

  Modified:    src/blocks/profiler/samples profile2html.xsl
  Log:
  Updated to support all the latest features of the profiler.
  Also made the view somewhat cleaner by reducing the number of links.
  
  Revision  Changes    Path
  1.3       +122 -58   cocoon-2.1/src/blocks/profiler/samples/profile2html.xsl
  
  Index: profile2html.xsl
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/profiler/samples/profile2html.xsl,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- profile2html.xsl  20 Mar 2003 15:04:16 -0000      1.2
  +++ profile2html.xsl  21 Mar 2003 17:30:37 -0000      1.3
  @@ -4,66 +4,83 @@
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:profile="http://apache.org/cocoon/profiler/1.0";>
   
  +  <xsl:import href="xml2html.xsl"/>
  +
     <xsl:param name="sort"/>
  +  <xsl:param name="key"/>
  +  <xsl:param name="result"/>
  +  <xsl:param name="component"/>
   
  -  <xsl:template match="profile:profilerinfo">
  +  <xsl:template match="/">
       <html>
         <head>
           <title>Cocoon2 profile information [<xsl:value-of select="@date"/>]</title>
         </head>
         <body>
  -        Sort results by <a href="?sort=uri">uri</a>,
  -        <a href="?sort=count">count</a>, <a href="?sort=time">time</a>.
  -
  -        <table noshade="noshade" border="0" cellspacing="1" cellpadding="0" 
width="100%">
  -          <xsl:choose>
  -            <xsl:when test="$sort = 'uri'">
  -              <xsl:apply-templates select="profile:pipeline">
  -                 <xsl:sort select="@uri"/>
  -              </xsl:apply-templates>
  -            </xsl:when>
  -            <xsl:when test="$sort = 'time'">
  -              <xsl:apply-templates select="profile:pipeline">
  -                 <xsl:sort select="@time" data-type="number"/>
  -              </xsl:apply-templates>
  -            </xsl:when>
  -            <xsl:when test="$sort = 'count'">
  -              <xsl:apply-templates select="profile:pipeline">
  -                 <xsl:sort select="@count" data-type="number"/>
  -              </xsl:apply-templates>
  -            </xsl:when>
  -            <xsl:otherwise>
  -              <xsl:apply-templates/>
  -            </xsl:otherwise>
  -          </xsl:choose>
  -        </table>
  -
  -        <xsl:apply-templates 
select="profile:pipeline/profile:result/profile:environmentinfo"/>
  +        <xsl:choose>
  +          <xsl:when test="$component!=''">
  +            <xsl:apply-templates
  +              
select="profile:profilerinfo/profile:pipeline/profile:result/profile:[EMAIL PROTECTED]"
  +              mode="fragment"/>
  +          </xsl:when>
  +          <xsl:when test="$result!=''">
  +            <xsl:apply-templates 
select="profile:profilerinfo/profile:pipeline/profile:result" mode="result"/>
  +          </xsl:when>
  +          <xsl:otherwise>
  +            <xsl:apply-templates select="profile:profilerinfo" mode="pipelines"/>
  +          </xsl:otherwise>
  +        </xsl:choose>
         </body>
       </html>
     </xsl:template>
   
  +  <xsl:template match="profile:profilerinfo" mode="pipelines">
  +    Sort results by <a href="?sort=uri">uri</a>,
  +    <a href="?sort=count">count</a>, <a href="?sort=time">time</a>.
  +
  +    <table noshade="noshade" border="0" cellspacing="1" cellpadding="0">
  +      <xsl:choose>
  +        <xsl:when test="$sort = 'uri'">
  +          <xsl:apply-templates select="profile:pipeline">
  +            <xsl:sort select="@uri"/>
  +          </xsl:apply-templates>
  +        </xsl:when>
  +        <xsl:when test="$sort = 'time'">
  +          <xsl:apply-templates select="profile:pipeline">
  +            <xsl:sort select="@time" data-type="number"/>
  +          </xsl:apply-templates>
  +        </xsl:when>
  +        <xsl:when test="$sort = 'count'">
  +          <xsl:apply-templates select="profile:pipeline">
  +            <xsl:sort select="@count" data-type="number"/>
  +          </xsl:apply-templates>
  +        </xsl:when>
  +        <xsl:otherwise>
  +          <xsl:apply-templates/>
  +        </xsl:otherwise>
  +      </xsl:choose>
  +    </table>
  +  </xsl:template>
  +
     <xsl:template match="profile:pipeline">
       <xsl:if test="position() mod 5 = 1">
         <tr bgcolor="#FFC0C0">
  -       <th>NN</th>
  -       <th>Role (Source)</th>
  +       <th></th>
  +       <th>Component</th>
          <th>Average</th>
          <th colspan="10">Last Results</th>
         </tr>
       </xsl:if>
       <tr bgcolor="#C0C0FF">
        <td colspan="3">
  -      <a href="[EMAIL PROTECTED]">
          <font face="verdana"><strong><xsl:value-of select="@uri"/></strong></font>
          (<xsl:value-of select="@count"/> results,
  -       total time: <xsl:value-of select="@time"/>,
  -       average time: <xsl:value-of select="@time div @count"/>)
  -      </a>
  +       total time: <xsl:value-of select="@processingTime"/>,
  +       average time: <xsl:value-of select="profile:average/@time"/>)
        </td>
        <xsl:for-each select="profile:result">
         <td>
  -       <a href="?key={../@key}&amp;[EMAIL PROTECTED]">
  +       <a href="?key={../@key}&amp;[EMAIL PROTECTED]">
           <xsl:value-of select="@index"/>
          </a>
         </td>
  @@ -78,14 +95,15 @@
         <tr bgcolor="{$bgcolor}">
   
          <xsl:variable name="pos" select="position()"/>
  -       <td width="1%">
  +       <td>
           <xsl:value-of select="$pos"/>
          </td>
  -       <td width="10%">
  -        <xsl:value-of select="@role"/>
  -        <xsl:if test="@source">
  -          (<xsl:value-of select="@source"/>)
  -        </xsl:if>
  +       <td>
  +         <xsl:value-of select="@role"/>
  +         <xsl:text>&#160;</xsl:text>
  +         <xsl:if test="@source">
  +           <i>src=</i><xsl:value-of select="@source"/>
  +         </xsl:if>
          </td>
   
          <xsl:for-each 
select="../../profile:average/profile:component[position()=$pos]">
  @@ -96,9 +114,7 @@
   
          <xsl:for-each 
select="../../profile:result/profile:component[position()=$pos]">
           <td>
  -         <a href="?key={../../@key}&amp;index={../@index}&amp;[EMAIL PROTECTED]">
             <xsl:value-of select="@time"/>
  -         </a>
           </td>
          </xsl:for-each>
   
  @@ -107,10 +123,10 @@
   
          <xsl:variable name="pos" select="count(profile:average/profile:component)"/>
         <tr>
  -       <td width="1%">
  +       <td>
           <xsl:value-of select="$pos+1"/>
          </td>
  -       <td width="10%">
  +       <td>
           TOTAL
          </td>
   
  @@ -127,18 +143,66 @@
         </tr>
     </xsl:template>
   
  -  <xsl:template match="profile:average|profile:result">
  -   <xsl:apply-templates/>
  -  </xsl:template>
  +  <xsl:template match="profile:result" mode="result">
  +    <h1><xsl:value-of select="profile:environmentinfo/profile:uri"/></h1>
  +    <table>
  +      <tr bgcolor="#FFC0C0">
  +        <th></th>
  +        <th>Component</th>
  +        <th colspan="3">Results</th>
  +      </tr>
  +      <tr bgcolor="#C0C0FF">
  +        <td colspan="2">
  +          <font face="verdana"><strong><xsl:value-of 
select="profile:environmentinfo/profile:uri"/></strong></font>
  +        </td>
  +        <td>Total Time</td>
  +        <td>Setup Time</td>
  +        <td>Processing Time</td>
  +        <td/>
  +      </tr>
   
  -  <xsl:template match="profile:component">
  -   <table cellspacing="0" cellpadding="0">
  -    <tr>
  -     <td>
  -      <xsl:value-of select="@role"/>
  -     </td>
  -    </tr>
  -   </table>
  +      <xsl:for-each select="profile:component">
  +        <xsl:variable name="bgcolor">
  +          <xsl:if test="position() mod 2 = 0">#D0D0D0</xsl:if>
  +          <xsl:if test="position() mod 2 = 1">#E0E0E0</xsl:if>
  +        </xsl:variable>
  +        <tr bgcolor="{$bgcolor}">
  +
  +          <xsl:variable name="pos" select="position()"/>
  +          <td>
  +            <xsl:value-of select="$pos"/>
  +          </td>
  +          <td>
  +            <xsl:value-of select="@role"/>
  +            <xsl:text>&#160;</xsl:text>
  +            <xsl:if test="@source">
  +              <i>src=</i><xsl:value-of select="@source"/>
  +            </xsl:if>
  +          </td>
  +
  +          <td>
  +            <xsl:value-of select="@time"/>
  +          </td>
  +
  +          <td>
  +            <xsl:value-of select="@setup"/>
  +          </td>
  +
  +          <td>
  +            <xsl:value-of select="@processing"/>
  +          </td>
  +
  +          <td>
  +            <xsl:if test="position() != last()">
  +              <a href="profile.xml?key={$key}&amp;result={$result}&amp;[EMAIL 
PROTECTED]&amp;fragmentonly=true">[XML]</a>
  +              &#160;&#160;
  +              <a href="profile.xml?key={$key}&amp;result={$result}&amp;[EMAIL 
PROTECTED]&amp;fragmentonly=true&amp;cocoon-view=pretty-content">[XML as HTML]</a>
  +            </xsl:if>
  +          </td>
  +        </tr>
  +      </xsl:for-each>
  +    </table>
  +    <xsl:apply-templates select="profile:environmentinfo"/>
     </xsl:template>
   
     <xsl:template match="profile:environmentinfo">
  @@ -149,7 +213,7 @@
     <xsl:template match="profile:request-parameters">
       <table>
         <tr bgcolor="#C0C0FF">
  -       <th colspan="14">
  +       <th colspan="2">
           Request parameters
          </th>
         </tr>
  @@ -174,7 +238,7 @@
     <xsl:template match="profile:session-attributes">
       <table>
         <tr bgcolor="#C0C0FF">
  -       <th colspan="14">
  +       <th colspan="2">
           Session attributes
          </th>
         </tr>
  
  
  

Reply via email to