I would suggest creating a template html file like the following

template_html.txt
================
<html><body>
_CONTENTS_
</body></html>

Then use <loadfile> to load the contents of the text file into a property and 
<copy> and <replace> to create the new html file. Something like...

<loadfile property="contents" srcfile="report.output"/>
<copy file="template_html.txt" tofile="report.outut.html"/>
<replace file="report.output.html" token="_CONTENTS_" value="${contents}"/>

If you have a directory full of these text files, you could make all the values 
above properties and loop over the files using ant-contrib's <foreach> task 
(google "ant-contrib").

-Rob A

> -----Original Message-----
> From: James Abley [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, May 11, 2006 12:52 AM
> To: Ant Users List
> Subject: Re: Add html tags in a text file
> 
> ANT build files are XML, thus, you need to ensure that it's 
> well-formed, or (more probably in this case) escape any tags, 
> use CDATA, or similar:
> 
> &lt;html&gt;&lt;body&gt;
> 
> <![CDATA[<html><body>]]>
> 
> etc,
> 
> File rename - use a glob mapper
> 
> http://ant.apache.org/manual/CoreTypes/mapper.html
> 
> Cheers,
> 
> James
> 
> Mikael Petterson (KI/EAB) wrote:
> > When I add the following:
> > 
> > <concat destfile="${basedir}/test_info/report.output">
> >     <path>
> >      <fileset dir="${basedir}/test_info/excemptions" 
> includes="*.txt"/>
> >     </path>
> >     <header filtering="no" trimleading="yes">
> >      <html><body>
> >     </header>
> >     <footer filtering="no" trimleading="yes">
> >      </body></html>
> >     </footer>
> >    </concat>
> > 
> > I get the following error:
> > 
> >  The element type "body" must be terminated by the matching 
> end-tag "</body>".
> > 
> > 
> > Also I forgot to mention that I have a directory of text 
> files that I 
> > want to add html tags into and change the extension. Does 
> that change the approach?
> > 
> > Cheers,
> > 
> > //mikael
> >  
> > 
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > Sent: den 11 maj 2006 07:42
> > To: user@ant.apache.org
> > Subject: AW: Add html tags in a text file
> > 
> > <concat> with <header> and <footer>.
> > <move>/<copy> with <filterchain><concatfilter append="" prepend=""/>
> > 
> > 
> > Jan
> > 
> > 
> >>-----Ursprüngliche Nachricht-----
> >>Von: Mikael Petterson (KI/EAB) 
> [mailto:[EMAIL PROTECTED]
> >>Gesendet: Donnerstag, 11. Mai 2006 07:34
> >>An: user@ant.apache.org
> >>Betreff: Add html tags in a text file
> >>
> >>Hi,
> >>
> >>I have a plain text file. I need to insert <html> at the very 
> >>beginning of the file and at the very end (</html>). And 
> then change 
> >>the file extension.
> >>
> >>I shell script I could use something like:
> >>
> >>cat $1 | sed "s/^/<html>/g" | \
> >>sed "s/$/<\/html>/g" >$1.html
> >>
> >>Is there a similar function in ant?
> >>
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED] For 
> additional 
> > commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED] For 
> additional 
> > commands, e-mail: [EMAIL PROTECTED]
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED] For 
> additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to