[MarkLogic Dev General] Size of xml and binary documents

Geert Josten geert.josten at dayon.nl
Tue Aug 14 07:29:19 PDT 2012


Hi Danny,



I think David is close. I’d use xdmp:unquote first on XML, and get the
string-length of that. For binary, you might want to try fn:data first,
which gives back a hexBinary. Not sure, might be unnecessary. String and
string-length of the hexBinary gives indeed twice the length.



I agree that certainly for the XML the length depends on serialization. And
it makes sense to put it in a doc property to prevent calculating it at
each request..



Kind regards,

Geert



*Van:* general-bounces at developer.marklogic.com [mailto:
general-bounces at developer.marklogic.com] *Namens *David Lee
*Verzonden:* dinsdag 14 augustus 2012 15:40
*Aan:* MarkLogic Developer Discussion
*Onderwerp:* Re: [MarkLogic Dev General] Size of xml and binary documents



Ah 4.2, missed that.



The best I can find so far is :



   fn:string-length( xs:string($node)) idiv 2



I would love to hear of a better solution.









-----------------------------------------------------------------------------

David Lee
Lead Engineer
MarkLogic Corporation
dlee at marklogic.com
Phone: +1 650-287-2531
Cell:  +1 812-630-7622
www.marklogic.com

This e-mail and any accompanying attachments are confidential. The
information is intended solely for the use of the individual to whom it is
addressed. Any review, disclosure, copying, distribution, or use of this
e-mail communication by others is strictly prohibited. If you are not the
intended recipient, please notify us immediately by returning this message
to the sender and delete all copies. Thank you for your cooperation.



*From:* general-bounces at developer.marklogic.com [mailto:
general-bounces at developer.marklogic.com] *On Behalf Of *Danny Sinang
*Sent:* Tuesday, August 14, 2012 9:15 AM
*To:* MarkLogic Developer Discussion
*Subject:* Re: [MarkLogic Dev General] Size of xml and binary documents



Hi David,



Thanks, but xdmp:binary-size() doesn't seem to be available on ML 4.2 , am
I correct ? If so, what is my alternative ?



Regards,
Danny



On Tue, Aug 14, 2012 at 9:08 AM, David Lee <David.Lee at marklogic.com> wrote:

For XML documents the size is not defined exactly.  What is stored on disk
is not the text serialized form, and there are multiple serialized forms
for an XML document.

You can retrieve the document and convert it to a string like



    fn:string-length( xs:string(doc("file.xml")))



That should give you something close but is a heavy operation (requires
fetching and serializing the document) and may or may not be the same size
as when you really extract and store the document.



For binary documents see:



http://developer.marklogic.com/pubs/5.0/apidocs/Ext-7.html#xdmp:binary-size





But like XML documents you  need to extract the document to calculate its
size.



Another proposition is to store as a document property the size ... again,
for XML this size is not a constant but a function of the serialization
used.



-----------------------------------------------------------------------------

David Lee
Lead Engineer
MarkLogic Corporation
dlee at marklogic.com
Phone: +1 650-287-2531
Cell:  +1 812-630-7622
www.marklogic.com

This e-mail and any accompanying attachments are confidential. The
information is intended solely for the use of the individual to whom it is
addressed. Any review, disclosure, copying, distribution, or use of this
e-mail communication by others is strictly prohibited. If you are not the
intended recipient, please notify us immediately by returning this message
to the sender and delete all copies. Thank you for your cooperation.



*From:* general-bounces at developer.marklogic.com [mailto:
general-bounces at developer.marklogic.com] *On Behalf Of *Danny Sinang
*Sent:* Tuesday, August 14, 2012 9:03 AM
*To:* general
*Subject:* [MarkLogic Dev General] Size of xml and binary documents



Hi,



In ML 4.2, how do you get the size of both xml and binary documents ?



Regards,

Danny






_______________________________________________
General mailing list
General at developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20120814/6df717ae/attachment-0001.html 


More information about the General mailing list