ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Lenz <cml...@gmx.de>
Subject Re: Property resolution in a task
Date Mon, 17 Nov 2003 11:53:06 GMT
It should be much more efficient (and probably simpler) to just traverse the 
DOM and replace properties in-place:

   public void replaceProperties(Node n) throws DOMException {
     switch (n.getNodeType()) {
       case Node.ATTR_NODE:
       case Node.CDATA_SECTION_NODE:
       case Node.TEXT_NODE: {
         n.setValue(getProject().replaceProperties(n.getNodeValue()));
         break;
       }
       case Node.DOCUMENT_NODE:
       case Node.DOCUMENT_FRAGMENT_NODE:
       case Node.ELEMENT_NODE: {
         Node child = n.getFirstChild();
         while (child != null) {
           replaceProperties(child);
           child = child.getNextSibling();
         }
         break;
       }
       default: {
         // ignore all other node types
       }
     }
   }

[disclaimer: this is all untested code]

-chris

Jan.Materne@rzf.fin-nrw.de wrote:
>>Is there an Ant way to 'spider' a DOM node, replacing 
>>properties as it goes?
> 
> 
> I donĀ“t know such a thing. But you can do:
> - write the DOM to a String
> - use Project.replace() on that String
> - parse the String
> - replace the DOM with new one
> 
> 
> Jan
> 


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


Mime
View raw message