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, '(("[^"]*")+|[^,]*),')
    for $group in $analyze//fn:group[@nr="1"]
    return
        if (matches($group, '^".+"$')) then
            replace($group, '^"([^"]+)"$', '$1')
        else
            $group/string()
};

Reply via email to