l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
September 2: Social gathering
Next Installfest:
TBD
Latest News:
Aug. 18: Discounts to "Velocity" in NY; come to tonight's "Photography" talk
Page last updated:
2010 Jul 14 20:32

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
[vox-tech] Fwd: Re: complex XML to CSV via XSLT
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vox-tech] Fwd: Re: complex XML to CSV via XSLT



Dylan posted from a non-sub'd addr.

-bill!

----- Forwarded message from vox-tech-bounces@lists.lugod.org -----

Date: Wed, 14 Jul 2010 14:15:52 -0700
From: vox-tech-bounces@lists.lugod.org
Subject: Auto-discard notification
To: vox-tech-owner@lists.lugod.org

The attached message has been automatically discarded.
Date: Wed, 14 Jul 2010 14:10:54 -0700
From: Dylan Beaudette <debeaudette@ucdavis.edu>
Subject: Re: [vox-tech] complex XML to CSV via XSLT
To: Harold Lee <harold@hotelling.net>
Cc: "lugod's technical discussion forum" <vox-tech@lists.lugod.org>
Reply-To: debeaudette@ucdavis.edu

Thanks!

That seemed to do the trick. However, I have a new problem.

The following works when I have a simple XML document with only 1 'pedon' 
per 'pedon_collection'

	<xsl:template match="pedon_collection/pedon/vegetation">
		<xsl:result-document href="vegetation.csv" format="csv">
		<xsl:apply-templates select="*" />
		</xsl:result-document>
	</xsl:template>

	<xsl:template match="vegetation_record">
		<xsl:apply-templates />
		<xsl:if test="following-sibling::*">
		<xsl:value-of select="$break" />
		</xsl:if>
	</xsl:template>
	
	<xsl:template match="vegetation_record/*">
		<!-- remove normalize-space() if you want keep white-space at it is --> 
		<xsl:value-of select="concat($quote, normalize-space(.), $quote)" />
		<xsl:if test="following-sibling::*">
		<xsl:value-of select="$delim" />
		</xsl:if>
	</xsl:template>

How can I apply these rules to _each_ 'pedon' in a 'pedon_collection', such 
the results are appended to the same file?

Thanks!
Dylan



On Wednesday 14 July 2010, Harold Lee wrote:
> If you want one XSLT program to output multiple files, then use the
> result-document instruction/element:
>
> http://www.w3.org/TR/xslt20/#element-result-document
>
> It allows you to specify all of the formatting options available via
> xsl:output, so you can output text - i.e. CSV - this way.
>
> Harold
>
> On Wed, Jul 14, 2010 at 11:40 AM, Dylan Beaudette
>
> <debeaudette@ucdavis.edu> wrote:
> > Hi,
> >
> > I have an XML file generated via PHP, and containing the contents of
> > several linked tables from a relational database. I would like to
> > generalize some sample XSLT documents to convert the entire file into a
> > sequence of CSV files. The XML file will essentially be exploded back
> > into a set of CSV files, one for each of the original tables. The idea
> > would be to create a couple XSLT files for converting the XML format into
> > several possible output formats.
> >
> > Attached is the XML file, as well as two XSLT files. I suppose that I
> > could loop over the tables of interest, and apply separate XSLT files to
> > the original XML-- saving to different output files each time. It would
> > be more convenient to have all of that logic embedded in the XSLT file--
> > if possible.
> >
> > Any ideas?
> >
> > Cheers,
> > Dylan
> >
> >
> > --
> > Dylan Beaudette
> > Soil Resource Laboratory
> > http://casoilresource.lawr.ucdavis.edu/
> > University of California at Davis
> > 530.754.7341
> >
> > _______________________________________________
> > vox-tech mailing list
> > vox-tech@lists.lugod.org
> > http://lists.lugod.org/mailman/listinfo/vox-tech



-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341


----- End forwarded message -----

-- 
-bill!
Sent from my computer
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Appahost Applications
For a significant contribution towards our projector, and a generous donation to allow us to continue meeting at the Davis Library.