Subject: Re: [xsl] Creating csv from multiple input files From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Tue, 06 May 2008 09:54:11 -0400 |
Cheers, Wendell
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>
</xsl:text>
</xsl:result-document>
</xsl:template>
<xsl:template match="//objid">
<xsl:value-of select="concat(.,'	')"/>
</xsl:template>
<xsl:template match="//cdate">
<xsl:value-of select="concat(.,'	')"/>
</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.
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Creating csv from multipl, Andrew Welch | Thread | RE: [xsl] Creating csv from multipl, Michael Kay |
Re: [xsl] Creating csv from multipl, Martin Honnen | Date | RE: [xsl] Creating csv from multipl, Michael Kay |
Month |