cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Cocoon Wiki] Update of "DP Filtering" by KermagoretJc
Date Mon, 12 Sep 2005 15:44:26 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Cocoon Wiki" for change notification.

The following page has been changed by KermagoretJc:
http://wiki.apache.org/cocoon/DP_Filtering

------------------------------------------------------------------------------
  
  = Usage =
  It may be used when you have files that differ only a little. Two elements, in http://bluexml.org/filter/1.0
namespace, are available :
- 
+ {{{
  <?xml version="1.0"?>
  
  <root xmlns:filter="">
      <A>
-         <filter:keep-current-element when="a"/>
+         <filter:keep-current-element when="onlya"/>
      </A>
      <B>
          <filter:keep-current-element when="nota"/>
      </B>
  </root>
- 
+ }}}
  It is useful when working with static files. If you dynamically generate your files, generate
directly the file you need, I think you will avoid problems.
  
  From a performance point of view, there is no impact because you will use it with configuration
files that are usually well cached by the system.
  
  = Structure/Architecture =
- [img src=""]
+ http://www.bluexml.org/static/images/filtering-dp.gif
  
  = Component =
- * filter:tags : tags in filter namespace and processed by the filter
+  * filter:tags : tags in filter namespace and processed by the filter
- * condition : the condition to encounter to realize the action indicated
+  * condition : the condition to encounter to realize the action indicated
+ 
+ If you take the above example :
+  * if condition is 'onlya', then only element A will be kept.
+  * if condition is 'nota', then only element B will be kept.
  
  = Implementation =
- It's a simple XSLT.
+ This is a very simple implementation that compares condition parameter with @when
  
+ {{{
  <!--|
      | CVS $Id: filter.xsl,v 1.4 2005/08/03 13:41:37 cvsjck Exp $
      |
@@ -51, +56 @@

      | verify the condition or not.
      |
      | @author jck@bluexml.com
-     | @copyright 2004-2005 Babel Objects SARL. All rights reserved.
+     | @copyright 2004-2005 BlueXML SARL. All rights reserved.
      |-->
  
  <xsl:stylesheet
@@ -62, +67 @@

  <!--|
      | Condition
      | Usually user's role, view, ... To be satisfied, the condition parameter
-     | must contain (include) the condition given in the @when attribute
+     | must contain (include) the string in @when attribute
      | For example :
      | * condition = role-dataadmin, when = dataadmin => verified
      | * condition = user-anonymous, when = dataadmin => not verified
@@ -79, +84 @@

      | @param @when the condition to verify
      | @returns the node if the condition is verified, nothing otherwise
      |
-     | @TODO : the conditions admin-create and create are realized the same way,
+     | @TODO : the conditions admin-create and create are realized the same way.
+     | It may be considered like a bug :-)
      |-->
  <xsl:template match="*[filter:delete-current-node]">
      <xsl:variable name="results">
@@ -125, +131 @@

      </xsl:if>
  </xsl:template>
  
- <!--|
-     | build-rtf : builds a rtf <parameters><parameter></parameter></parameters>
from parameters provided in query string format
-     |-->
- <xsl:template name="build-rtf">
-     <xsl:param name="parameters"/>
-     
-     <xsl:for-each select="$parameters">
-         <xsl:if test="'' != normalize-space(substring-before(.,'='))">
-             <parameter>
-                 <xsl:attribute name="name"><xsl:value-of select="normalize-space(substring-before(.,'='))"/></xsl:attribute>
-                 <xsl:attribute name="value"><xsl:value-of select="substring-after(.,'=')"/></xsl:attribute>
-             </parameter>            
-         </xsl:if>
-     </xsl:for-each>
- </xsl:template>
- 
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()" />
@@ -148, +138 @@

  </xsl:template>
  
  </xsl:stylesheet>
- 
+ }}}
  
  = Conclusion =
  

Mime
View raw message