Any improvement would be minor, I think. The cost of actually inserting the new 
fragment will swamp the extra CPU cost of evaluating a few XQuery functions, 
and all the data used by the XQuery function would have to be brought into 
memory either way.

I think the philosophy here is that this *can* be done in pure XQuery. So do it 
in pure XQuery, and show that people use it. That will help convince product 
management that it would be useful inside the server.

Personally I hardly ever rename documents: I try to design databases so that 
the document URIs are meaningful and are based on something immutable and 
unique within the document structure.

-- Mike

On 29 Jun 2011, at 10:20 , Geert Josten wrote:

> Another argument in favor of a built-in function would be performance gain, 
> if that is likely. In case you need/want to migrate a complete database 
> (potentially billions of documents or more)..
> 
> Adding the code of David to commons could help out in mean time though..
> 
> Kind regards,
> Geert
> 
> -----Oorspronkelijk bericht-----
> Van: [email protected] 
> [mailto:[email protected]] Namens Ron Hitchens
> Verzonden: woensdag 29 juni 2011 18:45
> Aan: General MarkLogic Developer Discussion
> Onderwerp: Re: [MarkLogic Dev General] Renaming a document
> 
> 
>   Umm, no.  My contention is that this should be
> a basic builtin, not an exercise left to the coder.
> It's too common and too easy to get wrong.
> 
> On Jun 29, 2011, at 5:05 PM, Eric Bloch wrote:
> 
>> Ron/David,
>> 
>> I'd encourage you to fork and make a pull request on the commons library at 
>> http://github.com/marklogic/commons where we've been keeping useful 
>> community library functions like this one.  
>> 
>> E
>> 
>> ________________________________________
>> From: [email protected] 
>> [[email protected]] On Behalf Of Justin Makeig 
>> [[email protected]]
>> Sent: Wednesday, June 29, 2011 6:26 AM
>> To: General MarkLogic Developer Discussion
>> Subject: Re: [MarkLogic Dev General] Renaming a document
>> 
>> Thanks for the feedback. I've noted the request and will be tracking it. As 
>> always, the input of the community is much appreciated.
>> 
>> Justin
>> 
>> 
>> Justin Makeig
>> Senior Product Manager
>> MarkLogic Corporation
>> [email protected]
>> Phone: +1 650 655 2387
>> 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.
>> 
>> 
>> On Jun 29, 2011, at 8:56 AM, Geert Josten wrote:
>> 
>>> +1 :)
>>> 
>>> -----Oorspronkelijk bericht-----
>>> Van: [email protected] 
>>> [mailto:[email protected]] Namens Ron Hitchens
>>> Verzonden: woensdag 29 juni 2011 14:50
>>> Aan: General MarkLogic Developer Discussion
>>> Onderwerp: Re: [MarkLogic Dev General] Renaming a document
>>> 
>>> 
>>> New Feature Request:
>>> 
>>>   xdmp:document-rename ($old-uri, $new-uri)
>>> 
>>> This is a very common requirement and is an
>>> intuitively obvious thing to do.  It should not
>>> require that a user research, write and debug a
>>> 23 line XQuery function to accomplish such a
>>> simple task.
>>> 
>>> On Jun 29, 2011, at 12:20 PM, Lee, David wrote:
>>> 
>>>> You may also want to copy the properties of the document and the 
>>>> properties object itself.
>>>> A full rename is a little complex.
>>>> 
>>>> Here's the query I use to implement rename in the xmlsh MarkLogic 
>>>> extension ... I got most of this off an older post -
>>>> I am not 100% sure its completely correct but it does appear to work.
>>>> 
>>>> --------------------  rename.xquery
>>>> 
>>>> xquery version "1.0-ml";
>>>> declare variable $src as xs:string external ;
>>>> declare variable $target as xs:string external ;
>>>> 
>>>> declare function local:document-rename(
>>>> $old-uri as xs:string, $new-uri as xs:string)
>>>> as empty-sequence()
>>>> {
>>>>  xdmp:document-delete($old-uri)
>>>>  ,
>>>>  let $permissions := xdmp:document-get-permissions($old-uri)
>>>>  let $collections := xdmp:document-get-collections($old-uri)
>>>>  return xdmp:document-insert(
>>>>    $new-uri, doc($old-uri),
>>>>    if ($permissions) then $permissions
>>>>    else xdmp:default-permissions(),
>>>>    if ($collections) then $collections
>>>>    else xdmp:default-collections(),
>>>>    xdmp:document-get-quality($old-uri)
>>>>  )
>>>>  ,
>>>>  let $prop-ns := namespace-uri(<prop:properties/>)
>>>>  let $properties :=
>>>>    xdmp:document-properties($old-uri)/node()
>>>>      [ namespace-uri(.) ne $prop-ns ]
>>>>  return xdmp:document-set-properties($new-uri, $properties)
>>>> };
>>>> 
>>>> local:document-rename($src,$target)
>>>> 
>>>> 
>>>> 
>>>> 
>>>> ----------------------------------------
>>>> David A. Lee
>>>> Senior Principal Software Engineer
>>>> Epocrates, Inc.
>>>> [email protected]
>>>> 812-482-5224
>>>> 
>>>> From: [email protected] 
>>>> [mailto:[email protected]] On Behalf Of Abhishek53 S
>>>> Sent: Tuesday, June 28, 2011 7:58 AM
>>>> To: General MarkLogic Developer Discussion
>>>> Subject: Re: [MarkLogic Dev General] Renaming a document
>>>> 
>>>> 
>>>> Hi Ambike,
>>>> 
>>>> It is not possible to update the URI of the document.  For that you need 
>>>> to get the content of existing and then insert the content with new 
>>>> document-uri and then delete the older content.
>>>> 
>>>> Regards
>>>> Abhishek Srivastav
>>>> Systems Engineer
>>>> Tata Consultancy Services
>>>> Cell:- +91-9883389968
>>>> Mailto: [email protected]
>>>> Website: http://www.tcs.com
>>>> ____________________________________________
>>>> Experience certainty.        IT Services
>>>>                     Business Solutions
>>>>                     Outsourcing
>>>> ____________________________________________
>>>> 
>>>> 
>>>> From:
>>>> ambika arumugam <[email protected]>
>>>> To:
>>>> General MarkLogic Developer Discussion <[email protected]>
>>>> Date:
>>>> 06/28/2011 05:20 PM
>>>> Subject:
>>>> [MarkLogic Dev General] Renaming a document
>>>> Sent by:
>>>> [email protected]
>>>> 
>>>> 
>>>> 
>>>> 
>>>> Hi all,
>>>> 
>>>> Is it possible in Marklogic to rename a document without really deleting 
>>>> the old document and then inserting the document with the required 
>>>> document name?
>>>> 
>>>> 
>>>> Regards
>>>> Ambika_______________________________________________
>>>> General mailing list
>>>> [email protected]
>>>> http://developer.marklogic.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://developer.marklogic.com/mailman/listinfo/general
>>> 
>>> ---
>>> Ron Hitchens {mailto:[email protected]}   Ronsoft Technologies
>>>   +44 7879 358 212 (voice)          http://www.ronsoft.com
>>>   +1 707 924 3878 (fax)              Bit Twiddling At Its Finest
>>> "No amount of belief establishes any fact." -Unknown
>>> 
>>> 
>>> 
>>> 
>>> _______________________________________________
>>> General mailing list
>>> [email protected]
>>> http://developer.marklogic.com/mailman/listinfo/general
>>> _______________________________________________
>>> General mailing list
>>> [email protected]
>>> http://developer.marklogic.com/mailman/listinfo/general
>> 
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
> 
> ---
> Ron Hitchens {mailto:[email protected]}   Ronsoft Technologies
>     +44 7879 358 212 (voice)          http://www.ronsoft.com
>     +1 707 924 3878 (fax)              Bit Twiddling At Its Finest
> "No amount of belief establishes any fact." -Unknown
> 
> 
> 
> 
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
> 

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to