Re: [basex-talk] csv:parse in the age of XQuery 3.1

2016-09-12 Thread Joe Wicentowski
Hi all, Forgive me. Rather than post more code in this thread, I've created a gist with revised code that resolves some inconsistencies in what I posted here earlier. https://gist.github.com/joewiz/7581205ab5be46eaa25fe223acda42c3 Again, this isn't a full-featured CSV parser by any means; it

Re: [basex-talk] csv:parse in the age of XQuery 3.1

2016-09-12 Thread Joe Wicentowski
And corrected query body: let $csv := 'Author,Title,ISBN,Binding,Year Published Jeannette Walls,The Glass Castle,074324754X,Paperback,2006 James Surowiecki,The Wisdom of Crowds,9780385503860,Paperback,2005 Lawrence Lessig,The Future of Ideas,9780375505782,Paperback,2002 "Larry Bossidy, Ram Charan,

Re: [basex-talk] csv:parse in the age of XQuery 3.1

2016-09-12 Thread Joe Wicentowski
Sorry, a typo crept in. Here's the corrected function: declare function local:get-cells($row as xs:string) as xs:string { (: workaround lack of lookahead support in XPath: end row with comma :) let $string-to-analyze := $row || "," let $analyze := fn:analyze-string($string-to-analyze,

Re: [basex-talk] csv:parse in the age of XQuery 3.1

2016-09-12 Thread Joe Wicentowski
Hi Christian, Yes, that sounds like the culprit. Searching back through my files, Adam Retter responded on exist-open (at http://markmail.org/message/3bxz55du3hl6arpr) to a call for help with the lack of lookahead support in XPath, by pointing to an XSLT he adapted for CSV parsing, https://github

Re: [basex-talk] csv:parse in the age of XQuery 3.1

2016-09-12 Thread Christian Grün
> Christian: I tried removing the quote escaping but still get an error. > Here's a small test to reproduce: > > fn:analyze-string($row, '(?:\s*(?:"([^"]*)"|([^,]+))\s*,?|(?<=,)(),?)+?') I assume it’s the lookbehind assertion that is not allowed in XQuery (but I should definitely spend more ti

Re: [basex-talk] csv:parse in the age of XQuery 3.1

2016-09-12 Thread Joe Wicentowski
Hi all, Christian: I completely agree, CSV is a nightmare. One way to reduce the headaches (in, say, developing an EXPath CSV library) might be to require that CSV pass validation by a tool such as http://digital-preservation.github.io/csv-validator/. Adam Retter presented his work on CSV Schema

Re: [basex-talk] csv:parse in the age of XQuery 3.1

2016-09-12 Thread Christian Grün
I didn’t check the regex in general, but one reason I think why it fails is the escaped quote. For example, the following query is illegal in XQuery 3.1… matches('a"b', 'a\"b') …where as the following one is ok: matches('a"b', 'a"b') On Mon, Sep 12, 2016 at 1:15 PM, Hans-Juergen Rennau w

Re: [basex-talk] csv:parse in the age of XQuery 3.1

2016-09-12 Thread Hans-Juergen Rennau
Cordial thanks, Liam - I was not aware of that! @Joe: Rule of life: when one is especially sure to be right, one is surely wrong, and so was I, and right were you(r first two characters). Liam R. E. Quin schrieb am 5:54 Montag, 12.September 2016: Hans-Jürgen, wrote: ! Already the first