One more thing. I've written the next code in GUI, and it works perfect.

let $fName := "test.csv"
let $content := file:read-text($fName, "cp1251")
let $csv := csv:parse($content, map{ 'separator': ';', 'header': false() } )
return $csv

What the difference between post data and raw file?


On Sun, Jun 12, 2016 at 11:45 PM, Alexander Shpack <shadowkin@gmail.com> wrote:
Did you always upload the same file?

Yeah


As the error indicates, it seems that your CSV input seems to contain
characters that are not valid in XML. There are various ways to tackle
this; one looks as follows:

 (: interpret client data as Base64 :)
 declare
    %rest:path("/upload")
    %rest:POST("{$body}")
    function local:store-csv($body as xs:base64Binary)
  {
    (: replace invalid characters with a question mark :)
    let $input := bin:from-octets(
      bin:to-octets($body) ! (if(. >= 32 or . = (9, 10, 13)) then . else 63)
    )
    (: convert to XQuery Unicode string; convert to XML :)
    let $string := bin:decode-string($input, 'CP1251')
    return csv:parse($string)
  };

There may be easier solutions as well (I’ll give you an update once I
remember them ;).

Strange solution... Ok, I'll wait for a better one.

--
s0rr0w



--
s0rr0w