ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject RE: Property resolution in a task
Date Mon, 17 Nov 2003 12:24:12 GMT
Ok, that comes from a guy who works more on DOM-Nodes than me (=nothing) :-)

Should we add that to Project class? (If we are allowed to do that)


Jan


> -----Original Message-----
> From: Upayavira [mailto:uv@upaya.co.uk]
> Sent: Monday, November 17, 2003 1:02 PM
> To: Ant Developers List
> Subject: Re: Property resolution in a task
> 
> 
> 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message