Re: [xsl] reading a .xsv file in xslt

Subject: Re: [xsl] reading a .xsv file in xslt
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Wed, 3 Feb 2010 10:56:29 +0000
On 3 February 2010 10:27, ac <ac@xxxxxxxxxxxxx> wrote:
> Hi Andrew,
> I am not sure that I understand well your point on QNames and
> normalize-space, as if the header line is missing from the csv, picking it
> up to try to derive element or attribute names from it is bound to generate
> invalid QName errors,

I thought you were saying there was occasionally a single blank line
before the header line?   As it stands the transform expects there to
be a header line... if you know your csv doesnt have a header line,
then its simple to modify the transform to put one in.  If you want it
to handle a unknown mixture of csv with and without headers, then you
are going beyond its original goal.

> '&#xa;' indeed displays as space in html but wouldn't '\r?\n' be more
> portable?

Yes, I have had the intention of correcting that for a while now :)

...but the people that pay get the priority.

> As a note on extending your example, the name for <root> and <row> could be
> parametrized and I think that I would move <root> further outside the nested
> code and allow $csvpath to be a space-delimited name list, for example, to
> easily support csv file merge into the tree, by simply looping over the
> tokenized file paths.

I would suggest that rather do it all in one transform, you leave the
csv-to-xml as one step, and do any further processing, such as
combining csvs, or transforming the xml into some other xml, as
subsequent steps in the pipeline.

> Your code offers a good basic design and I especially like your regex token
> grabber.

That was done with the help of this list :)

Andrew Welch

Current Thread