Hi Sudheer,


If you are sure it is text, but receive it as binary(), then following code
might help. string(data(..)) applied to binary() returns hexBinary as
string. The hex to integer and codepoints convert it to a real string. It
doesn’t treat encoding well, but it could be usefull. I use it to discover
encoding from xml-pi in some situations.



declare function scan:get-head($document as binary(), $length as

xs:integer) as xs:string {

               let $head := fn:string(fn:data(xdmp:subbinary($document, 1,
$length)))

               let $bytes :=

                              for $pos in (1 to $length)

                              return


xdmp:hex-to-integer(fn:substring($head, $pos * 2 - 1, 2))



               return

                              fn:codepoints-to-string($bytes)

};



There is also a binary-decode function, that might interest you..



Kind regards,

Geert



*Van:* [email protected] [mailto:
[email protected]] *Namens *Sudheer Yalaverthi
*Verzonden:* vrijdag 10 augustus 2012 22:38
*Aan:* MarkLogic Developer Discussion
*Onderwerp:* [MarkLogic Dev General] Reading multipart response in X-query



Hi Team,


I am making an http post call from xquery and this call returns a
multipart/mixed response.

Can anybody help on how to read the multipart response in x-query.

Also when i tried to read the multipart in the response, it is in the
binary form.

let $response := xdmp:http-post($uri,$options)
let $val := fn:data($response[2])
return if ($val instance of xs:hexBinary) then
              'hexbindary type'
         else 'unkonwn'

I am really not sure why it is coming as a binary data. how do i convert it
to a string in the x-query.

thanks.

Regards,
Sudheer
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to