No, browser doesn't want to send file content with this mime type. The other thing, RFC describes "text/csv" mime type. Are you sure that "text/comma-separated-values" is the correct one?


On Sun, Jun 12, 2016 at 9:41 PM, Christian Grün <christian.gruen@gmail.com> wrote:

Did you specify "text/comma-separated-values" as Content-Type?

Am 12.06.2016 8:05 nachm. schrieb "Alexander Shpack" <shadowkin@gmail.com>:
Thank you, Christian!

But it doesn't work as expected

declare
    %rest:path("/upload")
    %rest:POST("{$csv}")
    %input:csv("header=false,encoding=CP1251,separator=semicolon")
    %output:method("html")
    function page:uploadFile($csv as document-node())
        {
            $csv
        };


[XPTY0004] Cannot cast xs:string to document-node(): "?????????? ?....



On Sun, Jun 12, 2016 at 6:48 PM, Christian Grün <christian.gruen@gmail.com> wrote:
Hi Alex,

The following annotation should do what you want:

    %input:csv("header=true,encoding=CP1252")

You were completely right, the existing documentation was a bit
scrappy. I have slightly rewritten it (see [1] and outgoing links).

Hope thie helps,
Christian

[1] http://docs.basex.org/wiki/RESTXQ#Input_options




On Sun, Jun 12, 2016 at 4:03 PM, Alexander Shpack <shadowkin@gmail.com> wrote:
> Hi,
>
> I have nonstandard CSV file with semicolon instead of comma as a separator
> and cp1251 encoded. Documentation is not clear in this case, and the sample
> doesn't work properly
>
> declare
>   %rest:path("/store.csv")
>   %rest:POST("{$csv}")
>   %input:csv("header=true")
>   function page:store-csv($csv as document-node())
> {
>   "Number of rows: " || count($csv/csv/record)
> };
>
> Even if I changed the encoding manually the next code does nothing
> %input:csv("separator=semicolon")
> and returns text instead of document-node()
>
> Could you check it?
>
> It would be nice if you add additional encoding parameter to csv module.
>
> Thanks!



--
s0rr0w



--
s0rr0w