Re: [xsl] csv to xml converter bug

Subject: Re: [xsl] csv to xml converter bug
From: mcburton <mcburton@xxxxxxxxx>
Date: Tue, 10 Jul 2007 10:30:59 -0400
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.

This worked for my particular dataset(and time crunch), but I'm not
sure if it is a generic solution. I continue the search for the Holy
Regex...

--
mcb

On 7/10/07, Andrew Welch <andrew.j.welch@xxxxxxxxx> wrote:
On 7/10/07, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> The construct
>
> (?=X)
>
> is allowed in some regex dialects, it means "match X with a zero-width
> positive lookahead". But it's not allowed in the XPath regex dialect. This
> is basically an assertion that X must match at the current position, without
> causing X to be swallowed.
>
> This construct (a zero-width negative lookahead) isn't allowed either:
>
> (?!X)
>
> This is the inverse: it asserts that X does not match at the current
> position, without swallowing X.
>
> I'm afraid I have no idea whether these constructs can be translated into
> anything that the XPath regex dialect permits.
>
> Gunther Schadow can say "told you it would be needed":
> http://www.stylusstudio.com/xsllist/200412/post00810.html

Thanks for the explanation. Haven't heard from Gunther for a while...

The page gets quite a few hits so I think there is demand for a
de-facto csv-to-xml solution in XSLT... Hopefully someone skilled in
the dark arts of regex can fix the bug in the existing solution, or
perhaps convert the unsupported regex into something that is.

It certainly falls into the "rock hard" category of problems.

--
http://andrewjwelch.com

Current Thread