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
____________________________________________
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]] 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
=====-----=====-----=====
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