Re: [xsl] csv to xml converter bug

Subject: Re: [xsl] csv to xml converter bug
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Tue, 10 Jul 2007 15:54:42 +0100
On 7/10/07, mcburton <mcburton@xxxxxxxxx> wrote:
Gak! I was having the same problem last week. I have a complete hack solution:

I included leading & trailing commas in the analyze-string regex, but
in the "foo,bar",,"foo,bar",x,,,"foo,bar" case I was also getting
problematic parsing. Since the regex was looking for an extra comma I
added it, I did a search for "," and replaced it with ",,"
I then spent the next 2 hours in shower cleaning off the dirty.

I gave up dirty hacks long ago (and as you've said yourself, that was a dirty hack).

Processing XML seems to suffer from hacks - probably because of the
mysteries of encoding and entity resolution, but all to often I come
across double escaping and odd combinations of characters put there by
some well-meaning-but-oh-so-wrong programmer yet to discover forums
and mailings lists (that's the vast majority in my small corner),
trying to ndash and mdash to display correctly.

There's a rule I follow - "when you feel like using a delimeter - don't"

"Hmmm, maybe if we convert all commas inside quoted values to say,
pipes |, then we could just tokenize on comma and then covert the
pipes backs to commas..."

Seems kind of plausible, but will always come back to bite you in the
end.  (Contractors take note - you've normally left by then...)

--
http://andrewjwelch.com

Current Thread