Hi,

I wondered if there was a better way of writing the following query.
Basically it is a way of copying documents.

So if the document exists we want to insert the existing document into an
archive location and then store the latest version and if it doesn¹t exist
we just store it.

declare variable $documentUri := '{{docUri}}';
declare variable $documentArchiveUri := '{{docArchiveUri}}';
declare variable $xml as xs:string external;

if (xdmp:exists(doc($documentUri))) then (
    let $existingSitemap = doc($documentUri)
    xdmp:document-insert($documentArchiveUri,
xdmp:unquote($existingSitemap), xdmp:default-permissions(),
xdmp:default-collections())
    xdmp:document-insert($documentUri, xdmp:unquote($xml),
xdmp:default-permissions(), xdmp:default-collections())
) else (
    xdmp:document-insert($documentUri, xdmp:unquote($xml),
xdmp:default-permissions(), xdmp:default-collections())
)

This query actually complains, if I take out these lines it runs ok but
obviously doesn¹t do what I want:
let $existingSitemap = doc($documentUri)
xdmp:document-insert($documentArchiveUri, xdmp:unquote($existingSitemap),
xdmp:default-permissions(), xdmp:default-collections())

I wondered if there was a xdmp:document-copy type function?

Thanks
Jon

http://www.bbc.co.uk/
This e-mail (and any attachments) is confidential and may contain personal 
views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on 
it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.
                                        
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to