cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: r159641 - in cocoon/blocks/unsupported/xsp/trunk: java/org/apache/cocoon/components/language/markup/xsp/java/log.xsl samples/java/simple.xsp
Date Thu, 31 Mar 2005 21:19:34 GMT
Author: vgritsenko
Date: Thu Mar 31 13:19:34 2005
New Revision: 159641

URL: http://svn.apache.org/viewcvs?view=rev&rev=159641
Log:
fix bug #17771

Modified:
    cocoon/blocks/unsupported/xsp/trunk/java/org/apache/cocoon/components/language/markup/xsp/java/log.xsl
    cocoon/blocks/unsupported/xsp/trunk/samples/java/simple.xsp

Modified: cocoon/blocks/unsupported/xsp/trunk/java/org/apache/cocoon/components/language/markup/xsp/java/log.xsl
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/xsp/trunk/java/org/apache/cocoon/components/language/markup/xsp/java/log.xsl?view=diff&r1=159640&r2=159641
==============================================================================
--- cocoon/blocks/unsupported/xsp/trunk/java/org/apache/cocoon/components/language/markup/xsp/java/log.xsl
(original)
+++ cocoon/blocks/unsupported/xsp/trunk/java/org/apache/cocoon/components/language/markup/xsp/java/log.xsl
Thu Mar 31 13:19:34 2005
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!--
-  Copyright 1999-2004 The Apache Software Foundation
+  Copyright 1999-2005 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.
@@ -15,21 +15,26 @@
   limitations under the License.
 -->
 
-<!-- $Id: log.xsl,v 1.2 2004/03/17 11:28:22 crossley Exp $-->
-<!--
- * XSP Logger logicsheet for the Java language
- *
- * @author <a href="mailto:bloritsch@apache.org>Berin Loritsch</a>
- * @version CVS $Revision: 1.2 $ $Date: 2004/03/17 11:28:22 $
--->
-
-<xsl:stylesheet
-  version="1.0"
-  xmlns:xsp="http://apache.org/xsp"
-  xmlns:log="http://apache.org/xsp/log/2.0"
-
-  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
->
+<!--+
+    | XSP Logger logicsheet for the Java language
+    |
+    | @author <a href="mailto:bloritsch@apache.org>Berin Loritsch</a>
+    | @version $Id$
+    +-->
+<xsl:stylesheet version="1.0"
+                xmlns:xsp="http://apache.org/xsp"
+                xmlns:log="http://apache.org/xsp/log/2.0"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+  <xsl:template match="xsp:page">
+    <xsp:page>
+      <xsl:apply-templates select="@*"/>
+      <xsp:logic>
+        org.apache.avalon.framework.logger.Logger _log_defaultLogger;
+      </xsp:logic>
+      <xsl:apply-templates/>
+    </xsp:page>
+  </xsl:template>
 
   <xsl:template match="log:logger">
     <xsl:variable name="name">
@@ -40,24 +45,10 @@
             <xsl:with-param name="content" select="log:name"/>
           </xsl:call-template>
         </xsl:when>
-        <xsl:otherwise>""</xsl:otherwise>
+        <xsl:otherwise>null</xsl:otherwise>
       </xsl:choose>
     </xsl:variable>
 
-<!-- Files are now under control of LogKitManager
-    <xsl:variable name="filename">
-      <xsl:choose>
-        <xsl:when test="@filename">"<xsl:value-of select="@filename"/>"</xsl:when>
-        <xsl:when test="filename">
-          <xsl:call-template name="get-nested-content">
-            <xsl:with-param name="content" select="log:filename"/>
-          </xsl:call-template>
-        </xsl:when>
-        <xsl:otherwise>""</xsl:otherwise>
-      </xsl:choose>
-    </xsl:variable>
--->
-
     <xsl:variable name="level">
       <xsl:choose>
         <xsl:when test="@level">"<xsl:value-of select="@level"/>"</xsl:when>
@@ -71,63 +62,57 @@
     </xsl:variable>
 
     <xsp:logic>
-      if (getLogger() == null) {
-          try {
-            String category = <xsl:value-of select="$name"/>;
-            org.apache.log.Logger logger = org.apache.log.Hierarchy.getDefaultHierarchy().getLoggerFor(
category );
-<!--
-            if (!"".equals(<xsl:value-of select="$filename"/>)) {
-                String file = this.avalonContext.get(org.apache.cocoon.Constants.CONTEXT_LOG_DIR)
+ <xsl:value-of select="$filename"/>;
-                org.apache.log.LogTarget[] targets = new org.apache.log.LogTarget[] {
-                    new org.apache.log.output.FileOutputLogTarget(file)
-                };
-                logger.setLogTargets(targets);
-            }
--->
-            logger.setPriority(org.apache.log.Priority.getPriorityForName(<xsl:value-of
select="$level"/>));
-            this.enableLogging(new org.apache.avalon.framework.logger.LogKitLogger(logger));
-          } catch (Exception e) {
-            getLogger().error("Could not create logger for \"" +
-                               <xsl:value-of select="$name"/> + "\".", e);
-          }
+      if (_log_defaultLogger == null) {
+        _log_defaultLogger = getLogger();
+      }
+      try {
+        String category = <xsl:value-of select="$name"/>;
+        if (category != null) {
+          enableLogging(_log_defaultLogger.getChildLogger(category));
+        } else {
+          enableLogging(_log_defaultLogger);
+        }
+      } catch (Exception e) {
+        getLogger().error("Could not create logger for \"" +
+                           <xsl:value-of select="$name"/> + "\".", e);
       }
     </xsp:logic>
   </xsl:template>
 
   <xsl:template match="log:debug">
     <xsp:logic>
-      if(getLogger() != null)
+      if (getLogger().isDebugEnabled())
         getLogger().debug(<xsl:call-template name="get-log-message"/>);
     </xsp:logic>
   </xsl:template>
 
   <xsl:template match="log:info">
     <xsp:logic>
-      if(getLogger() != null)
+      if (getLogger().isInfoEnabled())
         getLogger().info(<xsl:call-template name="get-log-message"/>);
     </xsp:logic>
   </xsl:template>
 
   <xsl:template match="log:warn">
     <xsp:logic>
-      if(getLogger() != null)
+      if (getLogger().isWarnEnabled())
         getLogger().warn(<xsl:call-template name="get-log-message"/>);
     </xsp:logic>
   </xsl:template>
 
   <xsl:template match="log:error">
     <xsp:logic>
-      if(getLogger() != null)
+      if (getLogger().isErrorEnabled())
         getLogger().error(<xsl:call-template name="get-log-message"/>);
     </xsp:logic>
   </xsl:template>
 
   <xsl:template match="log:fatal-error">
     <xsp:logic>
-      if(getLogger() != null)
-        getLogger().fatalError(<xsl:call-template name="get-log-message"/>);
+      getLogger().fatalError(<xsl:call-template name="get-log-message"/>);
     </xsp:logic>
   </xsl:template>
+
 
   <xsl:template name="get-nested-content">
     <xsl:param name="content"/>

Modified: cocoon/blocks/unsupported/xsp/trunk/samples/java/simple.xsp
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/xsp/trunk/samples/java/simple.xsp?view=diff&r1=159640&r2=159641
==============================================================================
--- cocoon/blocks/unsupported/xsp/trunk/samples/java/simple.xsp (original)
+++ cocoon/blocks/unsupported/xsp/trunk/samples/java/simple.xsp Thu Mar 31 13:19:34 2005
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!--
-  Copyright 1999-2004 The Apache Software Foundation
+  Copyright 1999-2005 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.
@@ -15,8 +15,10 @@
   limitations under the License.
 -->
 
-<!-- CVS $Id$ -->
-
+<!--+
+    | Simple XSP example.
+    | $Id$
+    +-->
 <xsp:page language="java"
           xmlns:xsp="http://apache.org/xsp"
           xmlns:xsp-request="http://apache.org/xsp/request/2.0"
@@ -25,88 +27,85 @@
           xmlns:input="http://apache.org/cocoon/xsp/input/1.0">
 
   <page>
-   <log:logger name="xsp-sample" filename="xsp-sample.log"/>
-   <log:debug>Processing the beginning of the page</log:debug>
+    <!-- Use own logger sub-category for this logicsheet -->
+    <log:logger name="simple"/>
+    <log:debug>Processing the beginning of the page</log:debug>
+
+    <title>A Simple XSP Page</title>
+
+    <content>
+      <capture:fragment-variable name="page_part">
+        <para>
+          These 2 paragraphs were generated at the start of the XSP,
+          and captured for insertion at the end.
+        </para>
+        <para>Brought to you by Cocoon at <xsp:expr>new Date()</xsp:expr>.</para>
+      </capture:fragment-variable>
+
+      <para>Hi there! I'm a simple dynamic page generated by XSP (eXtensible Server
Pages).</para>
+
+      <para>I was requested as the URI: <b><xsp-request:get-uri as="xml"/></b></para>
+
+      <para>The following list was dynamically generated:</para>
+      <ul>
+        <xsp:logic>
+          for (int i=0; i &lt; 3; i++) {
+            <li>
+              Item <xsp:expr>i</xsp:expr>
+            </li>
+          }
+        </xsp:logic>
+      </ul>
+
+      <xsp:element>
+        <xsp:param name="name"><xsp:expr>"P".toLowerCase()</xsp:expr></xsp:param>
+        <xsp:attribute name="align">left</xsp:attribute>
+        <i>
+          This paragraph was dynamically generated by logic embedded in the page
+        </i>
+      </xsp:element>
+
+      <para>
+        Request parameter "name" as XML:
+        <xsp-request:get-parameter name="name" default="Not provided" as="xml"/>
+      </para>
+
+      <para>
+        Request parameter "name" as String:
+        <xsp-request:get-parameter name="name" default="Not provided"/>
+      </para>
+
+      <para>
+        Request parameter "name" as iso-8859-2 encoded String (with servlet
+        container encoding iso-8859-1):
+        <xsp-request:get-parameter name="name" default="Not provided"
+          form-encoding="iso-8859-2" container-encoding="iso-8859-1"/>
+      </para>
+
+      <xsp-request:get-parameter-values name="name"/>
+      <xsp-request:get-parameter-names/>
+
+      <para>
+        Header "user-agent" as XML:
+        <xsp-request:get-header name="user-agent" as="xml"/>
+      </para>
+
+      <para>
+        Header "user-agent" as String:
+        <xsp-request:get-header name="user-agent"/>
+      </para>
+
+      <para>
+        Access to input modules configured in cocoon.xconf:
+        <input:get-attribute module="cocoon-properties" name="fullname"/>
+        <input:get-attribute module="cocoon-properties" name="version"/>
+      </para>
 
-   <title>A Simple XSP Page</title>
+      <xsp-request:get-header-names/>
 
-   <content>
+      <xsp:expr>page_part</xsp:expr>
+    </content>
 
-   <capture:fragment-variable name="page_part">
-     <para>These 2 paragraphs were generated at the start of the XSP, and captured
for insertion at the end.</para>
-
-     <para>Brought to you by Cocoon at <xsp:expr>new Date()</xsp:expr>.</para>
-   </capture:fragment-variable>
-
-   <para>Hi there! I'm a simple dynamic page generated by XSP (eXtensible Server Pages).</para>
-
-   <para>I was requested as the URI: <b><xsp-request:get-uri as="xml"/></b></para>
-
-   <para>The following list was dynamically generated:</para>
-
-   <ul>
-     <xsp:logic>
-       <![CDATA[
-       for (int i=0; i<3; i++) {
-       ]]>
-         <li>
-           Item <xsp:expr>i</xsp:expr>
-         </li>
-       <![CDATA[
-       } 
-       ]]>
-     </xsp:logic>
-   </ul>
-
-   <xsp:element>
-     <xsp:param name="name"><xsp:expr>"P".toLowerCase()</xsp:expr></xsp:param>
-     <xsp:attribute name="align">left</xsp:attribute>
-     <i>
-       This paragraph was dynamically generated by logic embedded in the page
-     </i>
-   </xsp:element>
-
-   <para>
-     Request parameter "name" as XML:
-     <xsp-request:get-parameter name="name" default="Not provided" as="xml"/>
-   </para>
-
-   <para>
-     Request parameter "name" as String:
-     <xsp-request:get-parameter name="name" default="Not provided"/>
-   </para>
-
-   <para>
-     Request parameter "name" as iso-8859-2 encoded String (with servlet
-     container encoding iso-8859-1):
-     <xsp-request:get-parameter name="name" default="Not provided"
-       form-encoding="iso-8859-2" container-encoding="iso-8859-1"/>
-   </para>
-
-   <xsp-request:get-parameter-values name="name"/>
-
-   <xsp-request:get-parameter-names/>
-
-   <para>
-     Header "user-agent" as XML:
-     <xsp-request:get-header name="user-agent" as="xml"/>
-   </para>
-
-   <para>
-     Header "user-agent" as String:
-     <xsp-request:get-header name="user-agent"/>
-   </para>
-   
-   <para>
-     Access to input modules configured in cocoon.xconf: 
-     <input:get-attribute module="cocoon-properties" name="fullname"/>
-     <input:get-attribute module="cocoon-properties" name="version"/>
-   </para>
-
-   <xsp-request:get-header-names/>
-
-   <xsp:expr>page_part</xsp:expr>
-   </content>
-   <log:debug>Processing the end of the page</log:debug>
+    <log:debug>Processing the end of the page</log:debug>
   </page>
 </xsp:page>



Mime
View raw message