Thanks Mike! The binary constructor solved my problem. This is a great extension, I will check also the rest of the pdf, probably there are also other cool stuff.
----- Original Message ---- From: Michael Blakeley <[email protected]> To: General Mark Logic Developer Discussion <[email protected]> Sent: Sunday, July 26, 2009 9:29:46 PM Subject: Re: [MarkLogic Dev General] File upload with xforms You're very close, Tim. But as you've found out, a direct element constructor "<binary>..." just creates an element named binary, not a binary node. That's legal XQuery, but not very helpful. Instead, I believe you want the computed constructor for a binary node (aka "binary node constructor"). This is a MarkLogic Server extension, because the XQuery 1.0 data model doesn't include the concept of a binary node. Anyway, in either 0.9-ml or 1.0-ml you can write: binary { $content } Note that the binary node constructor can also handle xs:base64Binary directly: binary { xs:base64Binary("ABCD") } You can read more about binary constructors and other XQuery enhancements in the XQuery Reference Guide: http://developer.marklogic.com/pubs/4.1/books/xquery.pdf -- Mike On 2009-07-26 08:15, Tim Frosh wrote: > > Hi all, > > I am trying to upload files (binary and other) to database but need your help. > Using html forms and xdmp:get-request-field together with > xdmp:document-insert I succeed. > But I had not the same result using xforms. In xform, the binary data is > store in xml instance within an base64Binary element. > On the server side I decoded data and try to store like this: > > let $contentToStore := xs:hexBinary(xs:base64Binary($contentEncoded)) > let $work := xdmp:document-insert($doc, $contentToStore ) > > but get error $contentToStore is not a node. If I try to create an node using > the data as > let $contentToStore2 :=<binary> {$contentToStore}</binary> the data is > stored as text BUT not binary. > > The function document-insert doesn't have options for setting data format. > The documentation says that the root element of the node defines the data > format but I couldn't find any example how to set that. > > How can I create a binary node from the hexBinary data ? Or is there another > way for uploading files from xforms and base64Binary encoded data? > > Any help is appreciated. > > > > > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
