You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by ne...@apache.org on 2006/10/05 14:41:02 UTC

svn commit: r453206 - in /lenya/trunk/src/modules/profiling: ./ config/ config/menu.xsp menus.xmap module.xml resources/ sitemap.xmap xslt/ xslt/profile2xhtml.xsl xslt/test.xhtml xslt/test.xml xslt/xml2nicexml.xsl xslt/xml2xhtml.xsl

Author: nettings
Date: Thu Oct  5 05:41:01 2006
New Revision: 453206

URL: http://svn.apache.org/viewvc?view=rev&rev=453206
Log:
new profiling module (uses cocoon profiler).
adds a menu item to the "file" menu and provides
xslts for sourcecode prettyprinting and xml source
to xhtml rendering (very naive implementation atm).

Added:
    lenya/trunk/src/modules/profiling/
    lenya/trunk/src/modules/profiling/config/
    lenya/trunk/src/modules/profiling/config/menu.xsp   (with props)
    lenya/trunk/src/modules/profiling/menus.xmap   (with props)
    lenya/trunk/src/modules/profiling/module.xml   (with props)
    lenya/trunk/src/modules/profiling/resources/
    lenya/trunk/src/modules/profiling/sitemap.xmap   (with props)
    lenya/trunk/src/modules/profiling/xslt/
    lenya/trunk/src/modules/profiling/xslt/profile2xhtml.xsl   (with props)
    lenya/trunk/src/modules/profiling/xslt/test.xhtml
    lenya/trunk/src/modules/profiling/xslt/test.xml   (with props)
    lenya/trunk/src/modules/profiling/xslt/xml2nicexml.xsl   (with props)
    lenya/trunk/src/modules/profiling/xslt/xml2xhtml.xsl   (with props)

Added: lenya/trunk/src/modules/profiling/config/menu.xsp
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/profiling/config/menu.xsp?view=auto&rev=453206
==============================================================================
--- lenya/trunk/src/modules/profiling/config/menu.xsp (added)
+++ lenya/trunk/src/modules/profiling/config/menu.xsp Thu Oct  5 05:41:01 2006
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+   |
+   |  Lenya menu.xsp
+   |
+   -->
+
+
+<xsp:page xmlns:uc="http://apache.org/cocoon/lenya/usecase/1.0"
+          xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+          xmlns="http://apache.org/cocoon/lenya/menubar/1.0"
+          xmlns:xsp="http://apache.org/xsp"
+          language="java">
+   <menu>
+      <menus>
+         <menu i18n:attr="name" name="File">
+            <block admin="true">
+               <!-- 
+                    this is a semi-nasty kind of hack. the goal is to open 
+                    the profiler output in a separate window with javascript.
+                    the UsecaseMenuTransformer will only accept a href="" 
+                    attribute, i.e. we can't use onclick="" here. 
+                    to make sure the window always pops up in front, we
+                    we focus() it.
+                    at the same time, we want the original window to remain 
+                    unchanged, so we use the "void" operator to suppress the
+                    return value of the whole expression. 
+                -->
+               <item href="javascript: void window.open(
+                              '/modules/profiling/profile.html',
+                              'Cocoon Profiler',
+                              'location=yes,scrollbars=yes,menubar=no,'
+                              + 'toolbar=no,status=yes,top=100,left=100,'
+                              + 'height=500,width=700'
+                           ).focus()">
+                  <i18n:text>Profiling</i18n:text>
+               </item>
+            </block>
+         </menu>
+      </menus>
+   </menu>
+</xsp:page>
\ No newline at end of file

Propchange: lenya/trunk/src/modules/profiling/config/menu.xsp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/profiling/menus.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/profiling/menus.xmap?view=auto&rev=453206
==============================================================================
--- lenya/trunk/src/modules/profiling/menus.xmap (added)
+++ lenya/trunk/src/modules/profiling/menus.xmap Thu Oct  5 05:41:01 2006
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+   <map:pipelines>
+      <map:pipeline>
+         <map:match pattern="**">
+            <map:generate type="serverpages" src="config/menu.xsp"/>
+            <map:serialize type="xml"/>
+         </map:match>
+      </map:pipeline>
+   </map:pipelines>
+</map:sitemap>
\ No newline at end of file

Propchange: lenya/trunk/src/modules/profiling/menus.xmap
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/profiling/module.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/profiling/module.xml?view=auto&rev=453206
==============================================================================
--- lenya/trunk/src/modules/profiling/module.xml (added)
+++ lenya/trunk/src/modules/profiling/module.xml Thu Oct  5 05:41:01 2006
@@ -0,0 +1,10 @@
+<module xmlns="http://apache.org/lenya/module/1.0">
+  <id>org.apache.lenya.modules.profiling</id>
+  <package>org.apache.lenya.modules</package>
+  <version>0.0.3</version>
+  <name>Cocoon Pipeline Profiling Module</name>
+  <lenya-version>@lenya.version@</lenya-version>
+  <description>Makes the Cocoon profiling mechanism available to Lenya site
+administrators. See also
+http://cocoon.apache.org/2.1/userdocs/concepts/profiler.html</description>
+</module> 

Propchange: lenya/trunk/src/modules/profiling/module.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/profiling/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/profiling/sitemap.xmap?view=auto&rev=453206
==============================================================================
--- lenya/trunk/src/modules/profiling/sitemap.xmap (added)
+++ lenya/trunk/src/modules/profiling/sitemap.xmap Thu Oct  5 05:41:01 2006
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+
+<map:components>
+  <map:generators default="file">
+    <map:generator label="content,data" logger="sitemap.generator.profiler" name="profiler"
+        src="org.apache.cocoon.generation.ProfilerGenerator"/>
+  </map:generators>
+</map:components>
+
+<map:views>
+  <map:view name="pretty-content" from-label="data">
+    <map:transform src="xslt/xml2nicexml.xsl"/>
+    <map:transform src="xslt/xml2xhtml.xsl"/>
+    <map:serialize type="xhtml"/>
+  </map:view>
+</map:views>
+ 
+<map:pipelines>
+  <map:pipeline>
+    <map:match pattern="profile.html">
+      <map:generate type="profiler"/>
+      <map:transform src="xslt/profile2xhtml.xsl">
+        <map:parameter name="use-request-parameters" value="true"/>
+      </map:transform>
+      <map:serialize type="xhtml"/>
+    </map:match>
+    <map:match pattern="profile.xml">
+      <map:generate type="profiler"/>
+      <map:transform src="xslt/xml2nicexml.xsl"/>
+      <map:serialize type="xml"/>
+    </map:match>    
+  </map:pipeline>
+</map:pipelines>
+
+</map:sitemap>

Propchange: lenya/trunk/src/modules/profiling/sitemap.xmap
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/profiling/xslt/profile2xhtml.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/profiling/xslt/profile2xhtml.xsl?view=auto&rev=453206
==============================================================================
--- lenya/trunk/src/modules/profiling/xslt/profile2xhtml.xsl (added)
+++ lenya/trunk/src/modules/profiling/xslt/profile2xhtml.xsl Thu Oct  5 05:41:01 2006
@@ -0,0 +1,322 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:profile="http://apache.org/cocoon/profiler/1.0">
+
+  <xsl:param name="sort"/>
+  <xsl:param name="key"/>
+  <xsl:param name="result"/>
+  <xsl:param name="component"/>
+
+  <xsl:template match="/">
+    <html>
+      <head>
+        <title>Cocoon2 profile information [<xsl:value-of select="profile:profilerinfo/@date"/>]</title>
+      </head>
+      <body>
+        <xsl:choose>
+          <xsl:when test="$component!=''">
+            <xsl:apply-templates
+              select="profile:profilerinfo/profile:pipeline/profile:result/profile:component[@index=$component]"
+              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">
+    <xsl:choose>
+      <xsl:when test="not(profile:pipeline)">
+        <xsl:call-template name="help"/>
+      </xsl:when>
+      <xsl:otherwise>
+
+    <p>
+      Sort results by <a href="?sort=uri">uri</a>,
+      <a href="?sort=count">count</a>, <a href="?sort=time">time</a>.
+    </p>
+    <p>
+      Start at the section which matches the original request, then follow the
+      processing. The right-hand columns are the times (in milliseconds) for 
+      each occasion that a component was processed. The far right column is
+      the initial occasion.
+    </p>
+
+      
+    <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:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+
+  <xsl:template name="help">
+          <p>
+The <strong>Cocoon profiler</strong> is a great tool to debug and profile your pipelines.<br />
+In order to use it, change the type of the pipeline you want to inspect to "profile-noncaching", like so:
+          </p>
+<pre>
+
+  &lt;map:pipeline type="profile-noncaching"&gt;
+     ...
+  &lt;/map:pipeline&gt;
+</pre>
+          <p>
+Once you've done this, and you have sent a couple of requests to the pipeline in question, this page will disply 
+useful information about processing and setup time of the individual
+pipeline stages. What's even more interesting, you will be able to view the XML output of all stages!
+          </p>
+          <p>
+To make profiling work, the profiler block in Cocoon must be included, and the profiling pipeline type needs to be declared. 
+Lenya provides both by default.
+          </p>
+          <p>
+For more information, refer to 
+<a href="http://cocoon.apache.org/2.1/userdocs/concepts/profiler.html">the Cocoon documentation</a>.
+          </p>
+  </xsl:template>
+
+
+  <xsl:template match="profile:pipeline">
+    <xsl:if test="position() mod 5 = 1">
+      <tr bgcolor="#FFC0C0">
+       <th></th>
+       <th>Component</th>
+       <th>Average</th>
+       <th colspan="10">Last Results</th>
+      </tr>
+    </xsl:if>
+    <tr bgcolor="#C0C0FF">
+     <td colspan="3">
+       <font face="verdana"><strong><xsl:value-of select="@uri"/></strong></font>
+       (<xsl:value-of select="@count"/> results,
+       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;result={@index}">
+        <xsl:value-of select="@index"/>
+       </a>
+      </td>
+     </xsl:for-each>
+    </tr>
+
+    <xsl:for-each select="profile:average/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>
+
+       <xsl:for-each select="../../profile:average/profile:component[position()=$pos]">
+        <th>
+         <xsl:value-of select="@time"/>
+        </th>
+       </xsl:for-each>
+
+       <xsl:for-each select="../../profile:result/profile:component[position()=$pos]">
+        <td>
+          <xsl:value-of select="@time"/>
+        </td>
+       </xsl:for-each>
+
+      </tr>
+    </xsl:for-each>
+
+       <xsl:variable name="pos" select="count(profile:average/profile:component)"/>
+      <tr>
+       <td>
+        <xsl:value-of select="$pos+1"/>
+       </td>
+       <td>
+        TOTAL
+       </td>
+
+        <th>
+         <xsl:value-of select="profile:average/@time"/>
+        </th>
+
+       <xsl:for-each select="profile:result">
+        <td>
+         <xsl:value-of select="@time"/>
+        </td>
+       </xsl:for-each>
+
+      </tr>
+  </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: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;component={@index}&amp;fragmentonly=true">[XML]</a>
+              &#160;&#160;
+              <a href="profile.xml?key={$key}&amp;result={$result}&amp;component={@index}&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">
+   <xsl:apply-templates select="profile:request-parameters"/>
+   <xsl:apply-templates select="profile:session-attributes"/>
+  </xsl:template>
+
+  <xsl:template match="profile:request-parameters">
+    <table>
+      <tr bgcolor="#C0C0FF">
+       <th colspan="2">
+        Request parameters
+       </th>
+      </tr>
+      <tr bgcolor="#FFC0C0">
+        <th>Name</th>
+        <th>Value</th>
+      </tr>
+      <xsl:for-each select="profile:parameter">
+        <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}">
+          <td><xsl:value-of select="@name"/></td>
+          <td><xsl:value-of select="@value"/></td>
+        </tr>
+      </xsl:for-each>
+    </table>
+  </xsl:template>
+
+  <xsl:template match="profile:session-attributes">
+    <table>
+      <tr bgcolor="#C0C0FF">
+       <th colspan="2">
+        Session attributes
+       </th>
+      </tr>
+      <tr bgcolor="#FFC0C0">
+        <th>Name</th>
+        <th>Value</th>
+      </tr>
+      <xsl:for-each select="profile:attribute">
+        <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}">
+          <td><xsl:value-of select="@name"/></td>
+          <td><xsl:value-of select="@value"/></td>
+        </tr>
+      </xsl:for-each>
+    </table>
+  </xsl:template>
+
+</xsl:stylesheet>

Propchange: lenya/trunk/src/modules/profiling/xslt/profile2xhtml.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/profiling/xslt/test.xhtml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/profiling/xslt/test.xhtml?view=auto&rev=453206
==============================================================================
--- lenya/trunk/src/modules/profiling/xslt/test.xhtml (added)
+++ lenya/trunk/src/modules/profiling/xslt/test.xhtml Thu Oct  5 05:41:01 2006
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?><html xmlns="http://www.w3.org/1999/xhtml"><head><style type="text/css">
+         
+.highlight-elem {
+  color:green;
+}
+.highlight-attr {
+}
+.highlight-attrName {
+  color:blue;
+}
+.highlight-attrValue {
+  color:red;
+}
+.highlight-text {
+  color:grey;
+}
+
+.highlight-pi {
+  color:darkgrey;
+  font-weight:bold;
+  font-style:italic;
+}
+
+.highlight-comment {
+  color:#bbbbbb;
+  font-style:italic;
+}
+
+      </style></head><body><h1>XML Source Viewer</h1><span class="highlight-elem">&lt;root <span class="highlight-attr"><span class="highlight-attrName">attr</span>="<span class="highlight-attrValue">bogus</span>"</span>&gt;</span><br/>   <span class="highlight-text"/>   <span class="highlight-comment">&lt;!--  this is a comment  --&gt;</span><br/>   <span class="highlight-text"/><span class="highlight-pi">&lt;?foo "This is a processing Instruction" ?&gt;</span><br/>   <span class="highlight-text"/>   <span class="highlight-elem">&lt;tier <span class="highlight-attr"><span class="highlight-attrName">level</span>="<span class="highlight-attrValue">1</span>"</span>&gt;</span><br/>      <span class="highlight-text"/>      <span class="highlight-elem">&lt;info&gt;</span>         <span class="highlight-text">dork dork dork!</span><span class="highlight-elem">&lt;/info&gt;</span><br/>      <span cl
 ass="highlight-text"/>      <span class="highlight-elem">&lt;info <span class="highlight-attr"><span class="highlight-attrName">meta</span>="<span class="highlight-attrValue">leading whitespace</span>"</span>&gt;</span>         <span class="highlight-text">dork dork dork dork!</span><span class="highlight-elem">&lt;/info&gt;</span><br/>      <span class="highlight-text"/>      <span class="highlight-comment">&lt;!--  this is an indented comment  --&gt;</span><br/>      <span class="highlight-text"/>      <span class="highlight-elem">&lt;info <span class="highlight-attr"><span class="highlight-attrName">meta</span>="<span class="highlight-attrValue">trailing whitespace</span>"</span>&gt;</span>         <span class="highlight-text">dork!</span><span class="highlight-elem">&lt;/info&gt;</span><br/>      <span class="highlight-text"/>   <span class="highlight-elem">&
 lt;/tier&gt;</span><br/>   <span class="highlight-text"/>   <span class="highlight-elem">&lt;tier <span class="highlight-attr"><span class="highlight-attrName">level</span>="<span class="highlight-attrValue">2</span>"</span>/&gt;</span><br/>   <span class="highlight-text"/>   <span class="highlight-elem">&lt;tier <span class="highlight-attr"><span class="highlight-attrName">level</span>="<span class="highlight-attrValue">3</span>"</span> <span class="highlight-attr"><span class="highlight-attrName">comment</span>="<span class="highlight-attrValue">yeehah!</span>"</span>&gt;</span><br/>      <span class="highlight-text">Now for some</span>      <span class="highlight-elem">&lt;strong&gt;</span><br/>         <span class="highlight-elem">&lt;em&gt;</span>            <span class="highlight-text">seriously</span><span class="highlight-elem">&lt;/em&gt;</span><br/>         <
 span class="highlight-text"/>         <span class="highlight-elem">&lt;a <span class="highlight-attr"><span class="highlight-attrName">href</span>="<span class="highlight-attrValue">foo</span>"</span>&gt;</span>            <span class="highlight-text">mixed content</span><span class="highlight-elem">&lt;/a&gt;</span><br/>      <span class="highlight-elem">&lt;/strong&gt;</span><br/>      <span class="highlight-text">.</span>   <span class="highlight-elem">&lt;/tier&gt;</span><br/>   <span class="highlight-text"/><span class="highlight-elem">&lt;/root&gt;</span><br/><p>
+         Note: this source viewer is not very well tested, does not currently handle namespace nodes and mixed content formatting is very ugly.
+      </p></body></html>
\ No newline at end of file

Added: lenya/trunk/src/modules/profiling/xslt/test.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/profiling/xslt/test.xml?view=auto&rev=453206
==============================================================================
--- lenya/trunk/src/modules/profiling/xslt/test.xml (added)
+++ lenya/trunk/src/modules/profiling/xslt/test.xml Thu Oct  5 05:41:01 2006
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+
+<root xmlns="foo" attr="bogus">
+<!-- this is a comment -->
+<?foo "This is a processing Instruction" ?>
+  <tier level="1">
+     <info>dork dork dork!</info>
+     <info meta="leading whitespace"> dork dork dork dork!</info>
+     <!-- this is an indented comment -->
+     <info meta="trailing whitespace">dork!   </info>
+  </tier>
+  <tier level="2"/>
+  <tier level="3" comment="yeehah!">
+	  Now for some <strong><em>seriously</em> <a href="foo">mixed content</a></strong>.
+  </tier>
+</root>

Propchange: lenya/trunk/src/modules/profiling/xslt/test.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/profiling/xslt/xml2nicexml.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/profiling/xslt/xml2nicexml.xsl?view=auto&rev=453206
==============================================================================
--- lenya/trunk/src/modules/profiling/xslt/xml2nicexml.xsl (added)
+++ lenya/trunk/src/modules/profiling/xslt/xml2nicexml.xsl Thu Oct  5 05:41:01 2006
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- 
+   xml prettyprinter for apache cocoon/lenya, contributed by <ne...@apache.org>
+   everything that is non-trivial in this script has been borrowed from somewhere.
+   this script is in the public domain.
+-->
+
+<xsl:stylesheet version="1.0"
+      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:output method="xml"/>
+
+<xsl:param name="indent-increment" select="'  '" />
+
+  <!-- 
+    indentation
+    thanks to John Mongan, taken from http://www.dpawson.co.uk/xsl/sect2/pretty.html
+  -->
+
+  <xsl:template match="*">
+    <xsl:param name="indent" select="'&#xA;'"/>
+
+    <xsl:value-of select="$indent"/>
+
+    <xsl:copy>
+      <xsl:copy-of select="@*" />
+      <xsl:apply-templates>
+        <xsl:with-param name="indent" select="concat($indent, $indent-increment)"/>
+      </xsl:apply-templates>
+      <!-- add a trailing newline if the node has children and is not a mixed content node -->
+      <xsl:if test="* and not(*[../text()[normalize-space(.) != '']])">
+        <xsl:value-of select="$indent"/>
+      </xsl:if>
+    </xsl:copy>
+   </xsl:template>
+
+   <xsl:template match="comment()|processing-instruction()">
+      <xsl:copy />
+   </xsl:template>
+
+  <!-- 
+    mixed content detection and handling
+    thanks to David Carlisle and Wendell Piez, taken from http://www.dpawson.co.uk/xsl/sect2/normalise.html#d7206e52 
+  -->
+  <xsl:template match="*[../text()[normalize-space(.) != '']]">
+    <!-- but this template matches any element appearing in mixed content -->
+    <xsl:variable name="textbefore"
+         select="preceding-sibling::node()[1][self::text()]"/>
+    <xsl:variable name="textafter"
+         select="following-sibling::node()[1][self::text()]"/>
+    <!-- Either of the preceding variables will be an empty node set 
+         if the neighbor node is not text(), right? -->
+    <xsl:variable name="prevchar"
+         select="substring($textbefore, string-length($textbefore))"/>
+    <xsl:variable name="nextchar"
+         select="substring($textafter, 1, 1)"/>
+  
+    <!-- Now the action: -->
+    <xsl:if test="$prevchar != normalize-space($prevchar)">
+    <!-- If the original text had a space before, add one back -->
+      <xsl:text> </xsl:text>
+    </xsl:if>
+  
+    <xsl:copy>
+    <!-- Copy the element over -->
+      <xsl:copy-of select="@*"/>
+      <xsl:apply-templates/>
+    </xsl:copy>
+  
+    <xsl:if test="$nextchar != normalize-space($nextchar)">
+    <!-- If the original text had a space after, add one back -->
+      <xsl:text> </xsl:text>
+    </xsl:if>
+  
+  </xsl:template>
+
+<!--
+  normalize all whitespace in text nodes (i.e. those that don't get matched by the mixed content handler)
+-->
+  <xsl:template match="text()">
+    <xsl:value-of select="normalize-space(.)"/>
+  </xsl:template>
+
+</xsl:stylesheet>

Propchange: lenya/trunk/src/modules/profiling/xslt/xml2nicexml.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/profiling/xslt/xml2xhtml.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/profiling/xslt/xml2xhtml.xsl?view=auto&rev=453206
==============================================================================
--- lenya/trunk/src/modules/profiling/xslt/xml2xhtml.xsl (added)
+++ lenya/trunk/src/modules/profiling/xslt/xml2xhtml.xsl Thu Oct  5 05:41:01 2006
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- 
+   xml prettyprinter for apache cocoon/lenya, contributed by <ne...@apache.org>
+   everything that is non-trivial in this script has been borrowed from somewhere.
+   this script is in the public domain.
+-->
+
+<xsl:stylesheet version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns="http://www.w3.org/1999/xhtml"
+>
+
+<xsl:output method="xml"/>
+
+<xsl:variable name="indent" select="'&#160;&#160; '"/>
+
+<xsl:template match="/">
+  <html>
+    <head>
+      <style type="text/css">
+         
+.highlight-elem {
+  color:green;
+}
+.highlight-attr {
+}
+.highlight-attrName {
+  color:blue;
+}
+.highlight-attrValue {
+  color:red;
+}
+.highlight-text {
+  color:grey;
+}
+
+.highlight-pi {
+  color:darkgrey;
+  font-weight:bold;
+  font-style:italic;
+}
+
+.highlight-comment {
+  color:#bbbbbb;
+  font-style:italic;
+}
+
+      </style>
+    </head>
+    <body>
+      <h1>XML Source</h1>
+      <xsl:apply-templates />
+      <p>
+         Note: this source viewer is not very well tested, does not currently handle namespace nodes and mixed content formatting is very ugly.
+      </p>
+
+    </body>
+  </html>
+</xsl:template>
+
+<xsl:template match="*">
+  <xsl:param name="indentation"/>
+  <xsl:value-of select="$indentation"/>
+  <span class="highlight-elem">
+    <xsl:text>&lt;</xsl:text>
+    <xsl:value-of select="local-name()"/>
+    <xsl:apply-templates select="@*"/>
+    <xsl:text>&gt;</xsl:text>
+  </span>
+  <xsl:if test="*">
+    <br />
+  </xsl:if>
+  <xsl:apply-templates>
+    <xsl:with-param name="indentation" select="concat($indentation, $indent)"/>
+  </xsl:apply-templates>
+  <xsl:if test="*">
+  <xsl:value-of select="$indentation"/>
+  </xsl:if>
+  <span class="highlight-elem">
+  <xsl:text>&lt;/</xsl:text>
+  <xsl:value-of select="local-name()"/>
+  <xsl:text>&gt;</xsl:text>
+  </span>
+  <br />
+</xsl:template>
+
+<xsl:template match="*[not(node())]">
+  <xsl:param name="indentation"/>
+  <xsl:value-of select="$indentation"/>
+  <span class="highlight-elem">
+    <xsl:text>&lt;</xsl:text>
+    <xsl:value-of select="local-name()"/>
+    <xsl:apply-templates select="@*"/>
+    <xsl:text>/&gt;</xsl:text>
+  </span>
+  <br />
+</xsl:template>
+
+<xsl:template match="@*">
+  <xsl:text> </xsl:text>
+  <span class="highlight-attr">
+    <span class="highlight-attrName">
+      <xsl:value-of select="name()"/>
+    </span>
+    <xsl:text>="</xsl:text>
+    <span class="highlight-attrValue">
+      <xsl:value-of select="."/>
+    </span>
+    <xsl:text>"</xsl:text>
+  </span>
+</xsl:template>
+
+<xsl:template match="text()">
+  <xsl:param name="indentation"/>
+  <xsl:value-of select="$indentation"/>
+  <span class="highlight-text">
+    <xsl:value-of select="normalize-space(.)"/>
+  </span>
+</xsl:template>
+
+<xsl:template match="processing-instruction()">
+  <span class="highlight-pi">
+    <xsl:text>&lt;?</xsl:text>
+    <xsl:value-of select="name()"/>
+    <xsl:text> </xsl:text>
+    <xsl:value-of select="."/>
+    <xsl:text>?&gt;</xsl:text>
+  </span>
+  <br />
+</xsl:template>
+
+<xsl:template match="comment()">
+  <xsl:param name="indentation"/>
+  <xsl:value-of select="$indentation"/>
+  <span class="highlight-comment">
+    <xsl:text>&lt;!-- </xsl:text>
+    <xsl:value-of select="."/>
+    <xsl:text> --&gt;</xsl:text>
+  </span>
+  <br />
+</xsl:template>
+
+
+</xsl:stylesheet>

Propchange: lenya/trunk/src/modules/profiling/xslt/xml2xhtml.xsl
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org


Re: svn commit: r453206 - in /lenya/trunk/src/modules/profiling: ./ config/ config/menu.xsp menus.xmap module.xml resources/ sitemap.xmap xslt/ xslt/profile2xhtml.xsl xslt/test.xhtml xslt/test.xml xslt/xml2nicexml.xsl xslt/xml2xhtml.xsl

Posted by Jörn Nettingsmeier <po...@uni-duisburg-essen.de>.
josias, everyone,

nettings@apache.org wrote:
> Author: nettings
> Date: Thu Oct  5 05:41:01 2006
> New Revision: 453206
> 
> URL: http://svn.apache.org/viewvc?view=rev&rev=453206
> Log:
> new profiling module (uses cocoon profiler).
> adds a menu item to the "file" menu and provides
> xslts for sourcecode prettyprinting and xml source
> to xhtml rendering (very naive implementation atm).

please have a look at this little module. i have ripped out the nice but 
non-apache-compatible xmlverbatimwrapper and put in a really simple 
little syntax highlighter i wrote on the train an hour ago... it needs 
work but is already ok for debugging.

two open issues:

* the module provides a menu item via a menu.xmap/menu.xsp, but this 
mechanism seems to be bypassed in the default configuration, even when 
you register the module in publication.xconf. should we perhaps change this?
meanwhile, if you want to test the module with the default publication, 
visit http://localhost:8888/modules/profiling/profile.html


* the module currently sits in modules, because i found that 
modules-optional is not build by default, which does make sense now that 
i think about it. but i'm not sure where this module really belongs.
what is the contract with each of modules, modules-core and 
modules-optional? can we maybe put a README into src/ that documents this?

regards,

jörn


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org