ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <ste...@apache.org>
Subject Re: AW: csv to html via xslt or xslt2 task ?
Date Fri, 07 Mar 2008 17:27:52 GMT
Dan Stromberg wrote:
> 
> http://stromberg.dnsalias.org/~dstromberg/to-table.html
> 
> Jan.Materne@rzf.fin-nrw.de wrote:
>> XSLT needs XML as input - so CSV wouldnt work.
>> If you want to use XSLT you need the step of converting csv to xml 
>> before.
>>
>> Smallest way would use <script>:
>> - write html header
>> - iterate over the textfile line by line
>>   -- split the line by ","
>>   -- write the data line
>> - write html footer
>>
>> Mmh ... maybe AntContrib:for could iterate over textfiles - I dont know.
>>
>>
>> Jan
>>


I was doing some CSV work at work last week, turning spreadsheet columns 
into email. Life is a lot easier if you can push out the CSV as email, 
which you can get OpenOffice to do.

If you dont want to go that route (or want a batch process from CSV to 
HTML), use OpenCSV http://opencsv.sourceforge.net/ Its a nice little 
library which does the parsing. Set it up to run through your file and 
generate the XML that you then pump though XSL

*note that splitting the line by , isnt enough, you need to deal with 
quoted entries, commas in quotes, etc. Let someone else get the parser 
right.

FYI, the code I wrote is up here:
http://smartfrog.svn.sourceforge.net/viewvc/smartfrog/trunk/core/components/csvfiles/

-- 
Steve Loughran                  http://www.1060.org/blogxter/publish/5
Author: Ant in Action           http://antbook.org/

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


Mime
View raw message