cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cross...@apache.org
Subject cvs commit: cocoon-2.1/tools/src/anttasks XConfToolTask.java
Date Fri, 07 May 2004 18:32:45 GMT
crossley    2004/05/07 11:32:45

  Modified:    .        status.xml
               tools/src/anttasks XConfToolTask.java
  Log:
  Enable XConfToolTask to modify multiple attributes. See the bug report
  for description of use. Also enable suppression of comments.
  Submitted by: Ralph Goers
  Issue: 28704
  
  Revision  Changes    Path
  1.315     +5 -1      cocoon-2.1/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/status.xml,v
  retrieving revision 1.314
  retrieving revision 1.315
  diff -u -r1.314 -r1.315
  --- status.xml	7 May 2004 14:42:20 -0000	1.314
  +++ status.xml	7 May 2004 18:32:44 -0000	1.315
  @@ -212,6 +212,10 @@
     <changes>
   
    <release version="@version@" date="@date@">
  +   <action dev="DC" type="update" due-to="Ralph Goers" fixes-bug="28704">
  +     Enable XConfToolTask to modify multiple attributes. See the bug report
  +     for description of use. Also enable suppression of comments.
  +   </action>
      <action dev="UV" type="add">
        Extended FOM so that cocoon.redirectTo("url", true) will do a global 
        redirect. cocoon.redirectTo("url") will act as before. This enables
  
  
  
  1.26      +23 -1     cocoon-2.1/tools/src/anttasks/XConfToolTask.java
  
  Index: XConfToolTask.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/tools/src/anttasks/XConfToolTask.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- XConfToolTask.java	1 May 2004 16:12:05 -0000	1.25
  +++ XConfToolTask.java	7 May 2004 18:32:45 -0000	1.26
  @@ -28,6 +28,7 @@
   import org.apache.tools.ant.taskdefs.MatchingTask;
   import org.apache.tools.ant.types.XMLCatalog;
   import org.apache.xpath.XPathAPI;
  +import org.w3c.dom.Attr;
   import org.w3c.dom.DOMException;
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
  @@ -46,7 +47,9 @@
    * unless: (deprecated) xpath expression that must return empty node set
    * if-prop: use path file only when project property is set
    * remove: xpath expression to remove before adding nodes
  + * add-comments: if specified, overrides the ant task value
    * add-attribute: name of attribute to add to context node (requires value)
  + * add-attribute-<i>name</i>: add attribute <i>name</i> with the
specified value
    * value: value of attribute to add to context node (requires add-attribute)
    * insert-before: xpath expression, add new nodes before
    * insert-after: xpath expression, add new nodes after
  @@ -292,6 +295,25 @@
                   }
                   if (root instanceof Element) {
                       ((Element) root).setAttribute(name, value);
  +                }
  +            }
  + 
  +            // Override addComments from ant task if specified as an attribute
  +            String addCommentsAttr = getAttribute(elem, "add-comments", replaceProperties);
  +            if ((addCommentsAttr!=null) && (addCommentsAttr.length()>0)) {
  +                setAddComments(new Boolean(addCommentsAttr));
  +            }
  +
  +            // Allow multiple attributes to be added or modified
  +            if (root instanceof Element) {
  +                NamedNodeMap attrMap = elem.getAttributes();
  +                for (int i=0; i<attrMap.getLength(); ++i){
  +                    Attr attr = (Attr)attrMap.item(i);
  +                    final String addAttr = "add-attribute-";
  +                    if (attr.getName().startsWith(addAttr)) {
  +                        String key = attr.getName().substring(addAttr.length());
  +                        ((Element) root).setAttribute(key, attr.getValue());
  +                    }
                   }
               }
   
  
  
  

Mime
View raw message