Hi Santhosh, Perhaps xdmp:document-load might make things easier for you. You point to a location on your file system and can use the <format> option to specify text or binary. If you don't provide the <format> option, MarkLogic Server relies on the mime type settings to determine the datatype automatically.
Convertion text to hexdec and inserting as binary is unnecessary. Insert it as text node if possible, or let MarkLogic Server decide itself.. About XCC: I recommend looking at the ContentLoader example that is distributed together with XCC. Kind regards, Geert > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of > Danny Sokolsky > Sent: woensdag 9 september 2009 17:50 > To: General Mark Logic Developer Discussion > Subject: RE: [MarkLogic Dev General] How to insert binary or > text documentusing xdmp:document-insert() function - reg., > > Hi Santhosh, > > > > I am not a java expert, but I think you have to set the > contentCreateOptions to tell the insertContent method that > you are inserting binary content. I think you need to write > java code to actually create the binary content. > > > > Binary content is really intended for actual binary objects, > so I am not sure why you would want to convert text to binary. > > > > -Danny > > > > > > > > From: [email protected] > [mailto:[email protected]] On Behalf Of > Santhosh Raj > Sent: Tuesday, September 08, 2009 10:53 PM > To: General Mark Logic Developer Discussion > Subject: RE: [MarkLogic Dev General] How to insert binary or > text documentusing xdmp:document-insert() function - reg., > > > > > Hi Geert & Danny, > > Thanks for the information you gave. It is very usefull., > > Two more question for You. > > 1) How do the insertContent() function provided by xcc > insert binary data (.doc,.jpg and etc.,). > Does it convert each character to hexbinary and > convert to binary as you said. or any other way? > > Content content = ContentFactory.newContent(documentURI, > inputStream, contentCreateOptions); > session.insertContent(content); > > 2) converting each character to its hexadecimal > representation - Does't it affect the performance of the system. > > Thanks & Regards, > Santhosh Rajasekaran > > > > > From: > > Danny Sokolsky <[email protected]> > > To: > > General Mark Logic Developer Discussion > <[email protected]> > > Date: > > 09/08/2009 10:04 PM > > Subject: > > RE: [MarkLogic Dev General] How to insert binary or text > documentusing xdmp:document-insert() function - reg., > > Sent by: > > [email protected] > > > > ________________________________ > > > > > And to answer your previous question about documentation of > these constructors, Santhosh, the MarkLogic Server XQuery > Reference Guide > (http://developer.marklogic.com/pubs/4.1/books/xquery.pdf > <http://developer.marklogic.com/pubs/4.1/books/xquery.pdf> ) > mentions the binary constructor in the "MarkLogic Server > Enhanced XQuery Language" chapter. The XQuery standard > constructors are described in the "XQuery Language" chapter > and in the W3C XQuery recommendation > (http://www.w3.org/TR/xquery/#id-computedConstructors > <http://www.w3.org/TR/xquery/#id-computedConstructors> ). > > -Danny > > -----Original Message----- > From: [email protected] > [mailto:[email protected] > <mailto:[email protected]> ] On Behalf > Of Geert Josten > Sent: Tuesday, September 08, 2009 8:31 AM > To: General Mark Logic Developer Discussion > Subject: RE: [MarkLogic Dev General] How to insert binary or > text documentusing xdmp:document-insert() function - reg., > > Hi Santhosh, > > The "deadbeef" works because it is a string that can be > casted to xs:hexBinary, in other words it is a string > containing only digits or characters a-f. Converting plain > text to binary requires converting each character to its > hexadecimal representation. You can do that as follows: > > binary { > string-join(xdmp:integer-to-hex(string-to-codepoints("Testing > binary Constructor")), "") } > > But if you are really storing plain text, you could store > that as a text node just as well.. ;-) > > Kind regards, > Geert > > > > > > Drs. G.P.H. Josten > Consultant > > > http://www.daidalos.nl/ <http://www.daidalos.nl/> Daidalos BV > Source of Innovation Hoekeindsehof 1-4 > 2665 JZ Bleiswijk > Tel.: +31 (0) 10 850 1200 > Fax: +31 (0) 10 850 1199 > http://www.daidalos.nl/ <http://www.daidalos.nl/> KvK > 27164984 De informatie - verzonden in of met dit emailbericht > - is afkomstig van Daidalos BV en is uitsluitend bestemd voor > de geadresseerde. Indien u dit bericht onbedoeld hebt > ontvangen, verzoeken wij u het te verwijderen. Aan dit > bericht kunnen geen rechten worden ontleend. > > > > From: [email protected] > > [mailto:[email protected] > > <mailto:[email protected]> ] On Behalf Of > > Santhosh Raj > > Sent: dinsdag 8 september 2009 16:53 > > To: General Mark Logic Developer Discussion > > Subject: RE: [MarkLogic Dev General] How to insert binary or text > > document using xdmp:document-insert() function - reg., > > > > > > Hi Danny, > > > > The binary constructor which you provided is > working fine. But > > when i change the content "deadbeef" with some other value, It is > > giving Invalid Cast error. > > > > Eg: If I use > > > > xquery version "1.0-ml"; > > try { > > xdmp:document-insert("abc.doc", binary { "Testing binary > Constructor" > > } ) } catch ($e) { > > $e > > } > > > > Error: > > <error:code>XDMP-CAST</error:code> > > <error:name>err:FORG0001</error:name> > > <error:xquery-version>1.0-ml</error:xquery-version> > > <error:message>Invalid cast</error:message> > > <error:format-string>XDMP-CAST: (err:FORG0001) binary { "Testing > > binary Constructor" } -- Invalid cast: "Testing binary Constructor" > > cast as xs:hexBinary</error:format-string> > > <error:retryable>false</error:retryable> > > <error:expr>binary { "Testing binary Constructor" }</error:expr> > > > > When I just copy paste whatever you have sent then it is working. > > xquery version "1.0-ml"; > > xdmp:document-insert("notxml.xml", binary { "deadbeef" } ); > > xdmp:node-kind(doc("notxml.xml")/node()) > > => binary > > > > Please let me know what to do in this regard. > > > > Thanks and Regards, > > Santhosh Rajasekaran > > Tata Consultancy Services > > Mailto: [email protected] > > Website: http://www.tcs.com <http://www.tcs.com/> > > <http://www.tcs.com/ <http://www.tcs.com/> > > ____________________________________________ > > Experience certainty. IT Services > > Business Solutions > > Outsourcing > > ____________________________________________ > > > > > > > > From: Danny Sokolsky <[email protected]> > > To: General Mark Logic Developer Discussion > > <[email protected]> > > Date: 09/04/2009 10:07 PM > > Subject: RE: [MarkLogic Dev General] How to insert > > binary or text document using xdmp:document-insert() > > function - reg., > > Sent by: [email protected] > > > > ________________________________ > > > > > > > > > > You can use the text { } or binary { } or node constructors. > > xdmp:document-insert will load the document according to > the node kind > > of the 2nd parameter. For example, to store a text file with uri > > "notxml.xml", try something like this: > > > > xquery version "1.0-ml"; > > xdmp:document-insert("notxml.xml", text { "This is a text > node." } ); > > xdmp:node-kind(doc("notxml.xml")/node()) > > => text > > > > xquery version "1.0-ml"; > > xdmp:document-insert("notxml.xml", binary { "deadbeef" } ); > > xdmp:node-kind(doc("notxml.xml")/node()) > > => binary > > > > -Danny > > > > From: [email protected] > > [mailto:[email protected] > > <mailto:[email protected]> > > <mailto:[email protected] > > <mailto:[email protected]> > ] On Behalf Of > > Santhosh Raj > > Sent: Friday, September 04, 2009 7:46 AM > > To: [email protected] > > Subject: [MarkLogic Dev General] How to insert binary or > text document > > using xdmp:document-insert() function - reg., > > > > > > Hi all, > > > > I have to store .txt or .doc,.pdf files in marklogic server > > using xdmp:document-insert() function. > > > > In the Marklogic built-in functions it is represented as following: > > > > xdmp:document-insert( > > $uri as xs:string, > > $root as node(), > > [$permissions as element(sec:permission)*], [$collections as > > xs:string*], [$quality as xs:int?], [$forest-ids as > xs:unsignedLong*] > > ) as empty-sequence() > > > > > > $root : The root node. The root node can be one of XML > format, binary > > (BLOB) format, or text (CLOB) format. > > > > Eg: If i want to store a .txt file (sample.txt) with > content as "This > > is a sample text document." > > or > > If i want to store a .doc file (sample.doc) with content as > > "This is a sample word document" > > > > then how do i construct the root node of binary(BLOB) format or > > text(CLOB) format. > > > > How can i insert the document(text/doc) to database. > > > > > > Thanks and Regards, > > Santhosh Rajasekaran > > =====-----=====-----===== > > Notice: The information contained in this e-mail message and/or > > attachments to it may contain confidential or privileged > information. > > If you are not the intended recipient, any dissemination, > use, review, > > distribution, printing or copying of the information > contained in this > > e-mail message and/or attachments to it are strictly prohibited. If > > you have received this communication in error, please notify us by > > reply e-mail or telephone and immediately and permanently > delete the > > message and any attachments. Thank you > > > > > > _______________________________________________ > > General mailing list > > [email protected] > > http://xqzone.com/mailman/listinfo/general > > <http://xqzone.com/mailman/listinfo/general> > > <http://xqzone.com/mailman/listinfo/general > > <http://xqzone.com/mailman/listinfo/general> > > > > > > > > > =====-----=====-----===== > > Notice: The information contained in this e-mail message and/or > > attachments to it may contain confidential or privileged > information. > > If you are not the intended recipient, any dissemination, > use, review, > > distribution, printing or copying of the information > contained in this > > e-mail message and/or attachments to it are strictly prohibited. If > > you have received this communication in error, please notify us by > > reply e-mail or telephone and immediately and permanently > delete the > > message and any attachments. Thank you > > > > > > > > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general > <http://xqzone.com/mailman/listinfo/general> > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general > <http://xqzone.com/mailman/listinfo/general> > > > > =====-----=====-----===== > Notice: The information contained in this e-mail > message and/or attachments to it may contain > confidential or privileged information. If you are > not the intended recipient, any dissemination, use, > review, distribution, printing or copying of the > information contained in this e-mail message > and/or attachments to it are strictly prohibited. If > you have received this communication in error, > please notify us by reply e-mail or telephone and > immediately and permanently delete the message > and any attachments. Thank you > > > _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
