cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@cocoon.apache.org
Subject [Cocoon Wiki] Updated: XPatchTaskUsage
Date Fri, 27 Aug 2004 07:27:24 GMT
   Date: 2004-08-27T00:27:24
   Editor: RalphGoers <Ralph_Goers@dslextreme.com>
   Wiki: Cocoon Wiki
   Page: XPatchTaskUsage
   URL: http://wiki.apache.org/cocoon/XPatchTaskUsage

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -4,13 +4,13 @@
 
 == Task Definition ==
 The Cocoon build declares xpatch in init-tasks:
-{{{<taskdef name="xpatch" classname="XConfToolTask" classpath="${tools.tasks.dest}"/>
+{{{<taskdef name="xpatch" classname="XConfToolTask" classpath="${tools.tasks.dest}"/>
 }}}
 ;:''The source is found in tools/src/anttasks''
 
 == Xpatch element ==
-{{{<xpatch file="path/to/file.xml"
-            srcdir="base/path" 
+{{{<xpatch file="path/to/file.xml"
+            srcdir="base/path" 
             includes="**/*.patchtype"/> }}}
 ||'''Attribute'''||'''Description'''||||
 ||{{{file}}}||The file to modify||
@@ -25,9 +25,9 @@
  *  All child nodes of the root element of the patch file will be copied to the specified
location in the target file - including text and whitespace nodes.
 
 === ''Example'' (enable-uploads.xweb) ===
-{{{<xweb xpath="/web-app/servlet/init-param[param-name='enable-uploads']/param-value"
-	if-prop="config.enable-uploads"
-	remove="/web-app/servlet/init-param[param-name='enable-uploads']/param-value/text()"
+{{{<xweb xpath="/web-app/servlet/init-param[param-name='enable-uploads']/param-value"
+	if-prop="config.enable-uploads"
+	remove="/web-app/servlet/init-param[param-name='enable-uploads']/param-value/text()"
 >true</xweb>}}}
 ;:''Note the sensitivity to whitespace necessary in this case.''
 
@@ -39,8 +39,10 @@
 ||{{{remove}}}||(optional) An xpath expression of node(s) to remove before inserting this
patch.  Can be an alternative method for avoiding multiple insertions.  '''This expression
can return a node-set of more than one node.  All matching nodes will be removed'''||
 ||{{{insert-before}}}||(optional) An xpath expression that specifies where in the document
the patch will be placed.  by default, the expression is evaluated relative to the node specified
by the {{{xpath}}} attribute. If neither this nor {{{insert-after}}} are specified, the node
will be the last child node of the context specified in the {{{xpath}}} attribute.||
 ||{{{insert-after}}}||(optional) As above.  Ignored if {{{insert-before}}} is specified.||
+||{{{add-comments}}}||(optional) If specified, it overrides the ant task value||
 ||{{{add-attribute}}}||(optional) The name of an attribute to add to the context node specified
by {{{xpath}}}.  Only one attribute per patch file is supported.||
 ||{{{value}}}||(optional, but required if add-attribute is specified) The value to assign
to attribute specified in {{{add-attribute}}}||
+||add-attribute-''name''||(optional) Add attribute ''name'' with the specified value||
 ||{{{replace-properties}}}||(optional) By default, Ant properties are replaced with their
values throughout the patch file. If this becomes a problem (e.g. with JEXL expressions),
set {{{replace-properties}}} to false||
 
 ----
@@ -57,25 +59,33 @@
 
 Here's an example inserting the {{{load-class}}} directive ({{{web.xml}}}) for a database
driver in case it doesn't exist already. There's a catch with the {{{web.xml}}} structure
- you have to be rather precise where you insert another {{{init-param}}} element, since other
elements can appear on the same level, and the order is important.
 
-{{{<xweb unless="/web-app/servlet/init-param[param-name = 'load-class'][contains(param-value,'com.mysql.jdbc.Driver')]"
-      xpath="/web-app/servlet"
-      insert-after="init-param[position()=last()]">
-  <init-param>
-  	<param-name>load-class</param-name>
-  	<param-value>com.mysql.jdbc.Driver</param-value>
-  </init-param>
+{{{<xweb unless="/web-app/servlet/init-param[param-name = 'load-class'][contains(param-value,'com.mysql.jdbc.Driver')]"
+      xpath="/web-app/servlet"
+      insert-after="init-param[position()=last()]">
+  <init-param>
+  	<param-name>load-class</param-name>
+  	<param-value>com.mysql.jdbc.Driver</param-value>
+  </init-param>
 </xweb>}}}
 
 The {{{unless}}} attribute checks whether there exists an {{{init-param}}} already referring
to the mysql jdbc driver class, the {{{xpath}}} attribute points to the context (root) node
where the {{{init-param}}} will be inserted, and the {{{insert-after}}} contains another XPath
expression selecting the last already existing {{{init-param}}}, after which the new one will
be inserted. - StevenNoels
 
 ''This can lead to multiple 'load-class' entries. Does it work though? - JoergHeinicke''
 
-{{{
-<xweb xpath="/web-app/servlet/init-param[param-name='load-class']/param-value"
-      unless="/web-app/servlet/init-param[param-name='load-class'][contains(param-value,'com.mysql.jdbc.Driver')]"
-      insert-after="text()">
-   	  com.mysql.jdbc.Driver
-</xweb>
+{{{
+<xweb xpath="/web-app/servlet/init-param[param-name='load-class']/param-value"
+      unless="/web-app/servlet/init-param[param-name='load-class'][contains(param-value,'com.mysql.jdbc.Driver')]"
+      insert-after="text()">
+   	  com.mysql.jdbc.Driver
+</xweb>
 }}}
 
 ''This won't work if there is not already a 'load-class' entry. - JoergHeinicke''
+
+The next example adds the pool-grow attribute and the pool-min attribute, both with a vaule
of 2, and the pool-max attribute with a value of 50 to the encodeURL transformer definition.
It will not add comments to the output file.
+
+{{{
+<xmap xpath="/sitemap/components/transformers/transformer[@name='encodeURL']"
+  add-attribute-pool-grow="2" add-attribute-pool-max="50" add-attribute-pool-min="2"
+  add-comments="false"/>
+}}}

Mime
View raw message