xdmp:multipart-encode( $separator as xs:string, $manifest as element(), $content as node()* ) as binary()
Create a multipart encoding of the specified node. The returned binary node can be passed to xdmp:http-post. The manifest is modeled after the manifest that is passed to zip:create, with the headers element being the same as is described for xdmp:http-get allowing users to add arbitrary headers to each part. If a content-type header is not specified for a part, it will be determined if possible from the content.
There should be one part element for each node in the content sequence.
Each part also has an optional options node to control how xml or text will be serialized. The two options are the same as for xdmp:save.
<part> <headers> <Content-Type>image/jpeg</Content-Type> <headers> <options> <output-encoding>...</output-encoding> <output-sgml-character-entities>...</output-sgml-character-entities> </options> </part>
Parameters | |
---|---|
separator | The string that is to be used as a separator. |
$manifest | The manifest. |
$content | The nodes that are to be encoded. |
xquery version "1.0-ml"; let $html := document{ <html><p>Some stuff in an .html document</p></html> } let $xml := document{ <root><a>Some other stuff in a .xml document</a></root> } let $json := xdmp:to-json(("a",fn:false())) let $boundary-string := "gc0p4Jq0M2Yt08jU534c0p" return xdmp:multipart-encode( $boundary-string, <manifest> <part> <headers> <Content-Type>application/xml</Content-Type> <boundary>gc0p4Jq0M2Yt08jU534c0p</boundary> </headers> </part> <part> <headers> <Content-Type>text/html</Content-Type> </headers> </part> <part> <headers> <Content-Type>application/json</Content-Type> </headers> </part> </manifest>, ($xml,$html,$json) ) => --gc0p4Jq0M2Yt08jU534c0p Content-Type: application/xml boundary: gc0p4Jq0M2Yt08jU534c0p Content-Length: 94 <?xml version="1.0" encoding="UTF-8"?> <root><a>Some other stuff in a .xml document</a></root> --gc0p4Jq0M2Yt08jU534c0p Content-Type: text/html Content-Length: 90 <?xml version="1.0" encoding="UTF-8"?> <html><p>Some stuff in an .html document</p></html> --gc0p4Jq0M2Yt08jU534c0p Content-Type: application/json Content-Length: 12 ["a", false] --gc0p4Jq0M2Yt08jU534c0p--