ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Upayavira ...@upaya.co.uk>
Subject Re: Property resolution in a task
Date Mon, 17 Nov 2003 12:02:27 GMT
Christopher Lenz wrote:

> It should be much more efficient (and probably simpler) to just 
> traverse the DOM and replace properties in-place:

Splendid! This job gets easier by the moment!

Thanks for that.

Regards, Upayavira

>
>   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
>
>



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


Mime
View raw message