[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Creating csv from multiple input files

Subject: Creating csv from multiple input files
From: "Georg Hohmann" <georg.hohmann@xxxxxxxxx>
Date: Tue, 6 May 2008 15:24:56 +0200
 Creating csv from multiple input files
Hi,
this question has been asked a few times in this list but i couldn't
find an answer that works for me.
I want to process multiple xml-files in one folder and write the
output to one single file.

My input files are very simple and look like this:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<invdoc>
   <objid>3196575</objid>
   <cdate>15.02.2006</cdate>
   <user>Smith</user>
</invdox>

<?xml version="1.0" encoding="ISO-8859-1" ?>
<invdoc>
   <objid>3196576</objid>
   <cdate>15.02.2006</cdate>
   <user>Doe</user>
</invdox>

My XSLT ist very simple too and should create a csv-file where the
values are separated by tabulators:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output name="csv" method="text" encoding="UTF-8"/>
   <xsl:template match="/">
      <xsl:result-document format="csv" href="result.csv">
         <xsl:apply-templates/>
         <xsl:text>&#x0d;&#x0a;</xsl:text>
      </xsl:result-document>
   </xsl:template>
   <xsl:template match="//objid">
      <xsl:value-of select="concat(.,'&#00009;')"/>
   </xsl:template>
   <xsl:template match="//cdate">
      <xsl:value-of select="concat(.,'&#00009;')"/>
   </xsl:template>
   <xsl:template match="//user">
      <xsl:value-of select="."/>
   </xsl:template>
</xsl:stylesheet>

For a single file this works fine.
But the supposed output after processing all files should be a single
"result.csv" that looks like this:

3196575   15.02.2006   Smith
3196576   15.02.2006   Doe
4194550   07.03.2007   Smith

Given that i don't know the number and names of the files in the input
folder, how can i archive this result?

I'm using Saxon8 for the tranformation but couldn't find out how to
process multiple files on the command line. I also tried Kernow which
makes it easy to pass a folder to saxon, but i didn't manage to create
a single output file. It would be nice if someone could toss me to the
right direction. Is there a pure XSLT-solution or do i have to use
specific command-line options for saxon that i do not know?

Georg.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.