[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

regex in csv2xml

Subject: regex in csv2xml
From: "Jesper Tverskov" <jesper@xxxxxxxxxxx>
Date: Mon, 27 Mar 2006 09:51:29 +0200
csv2xml
Hi list,

I am trying to make a csv2xml XSLT 2.0 stylesheet using the Excel csv format
as example:
If delimiter, newline or quotes are part of data the data is quoted, quotes
are doubled.

My last problem is that the newline character can be part of data. I would
like to detect thise newline characters and replace them temporarily with
some unique code.
But have can I detect them in the first place?

Look at the sample below, we have 3 records and 3 fields:

34,"""yes"", I said",46
25,"I said:
""Hello"", and I added: ""nice day, stranger""
and, ""look at the sun"" , and: 
""bye for now.""",33
47,,35

Line 1 and 6 are records. We have an empty field in line 6.
But line 2, 3, 4, 5 are one record with three linefeeds and several commas
as part of data.

How can I detect with a regex, that the linefeeds at the end of line 2, 3
and 4 are part of data?
As I see it line 2 and 5 are the easy part, they will always have an uneven
number of quotes.
But the linefeeds in line 3 and 4 can only be detected as part of data if we
compare all the lines being part of a record?

Best regards,
Jesper Tverskov

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.