Hi Lanz,
Be carefull with 'catch($e) { }', I recommend adding an xdmp:log($e). You might
be missing an important warning here.
Can you also tell us exactly how you are verifying "collection-last"? Make sure
to check in a separate transaction.
Kind regards,
Geert
>
drs. G.P.H. (Geert) Josten
Consultant
Daidalos BV
Hoekeindsehof 1-4
2665 JZ Bleiswijk
T +31 (0)10 850 1200
F +31 (0)10 850 1199
mailto:[email protected]
http://www.daidalos.nl/
KvK 27164984
De informatie - verzonden in of met dit e-mailbericht - 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]] On Behalf Of Lanz
> Sent: vrijdag 6 augustus 2010 16:20
> To: general
> Subject: [MarkLogic Dev General]
> xdmp:document-remove-collections not working
>
> Hi all,
>
> I have an issue with xdmp:document-remove-collections, the
> way I use this function does not work.
> Here is my code explanation :
> 1- I want to move XML documents from one input directory to
> another one (in reality, delete and recreate document)
> 2 - with xdmp:document-insert I add some collections to the
> new document, 3 collections related to the date and one other
> which flags the document as the last one ("collection-last")
> 3- I need to keep only one document in the collection
> ("collection-last") : each time I "move" a document (see 1-)
> I remove all document from ("collection-last") and then I set
> ("collection-last") to the processed document.
>
> But it seems that I can't remove all documents from
> ("collection-last"), there is no error but it does not work at all :
> all document keep this collection
> Help is appreciated., Thanks !
> Lanz
>
>
> Here is my code :
> xquery version '1.0-ml';
>
> declare function
> local:clean-collection() as empty-sequence() { for $doc in
> fn:collection("collection-last") return
> xdmp:document-remove-collections(fn:document-uri($doc),
> ("collection-last"))
> };
> declare function
> local:document-move($targetURI as xs:string, $sourceURI as
> xs:string, $myCollection as xs:string*) as empty-sequence() {
> try {
> local:clean-collection(),
> xdmp:document-delete($sourceURI),
> let $permissions := xdmp:document-get-permissions($sourceURI)
> let $collections := $myCollection
> let $quality := xdmp:document-get-quality($sourceURI)
> return
> xdmp:document-insert(
> $targetURI,
> doc($sourceURI),
> if ($permissions)
> then $permissions
> else xdmp:default-permissions(),
> if ($collections)
> then $collections
> else xdmp:default-collections(),
> $quality ),
> let $prop-ns := namespace-uri(<prop:properties/>)
> let $properties := xdmp:document-properties($sourceURI)/node()
> [ namespace-uri(.) ne $prop-ns ]
> return xdmp:document-set-properties($targetURI, $properties)
> }
> catch($e) {
> }
> };
>
> (:scan du repertoire d'entrée:)
> for $doc in xdmp:directory("/data/items/input/")
>
> let $sourceURI := xdmp:node-uri($doc)
> let $myDate := doc($sourceURI)/Items/Item[1]/ExportDate
> let $myYeardate := fn:year-from-date(xs:date($myDate))
> let $targetDir :=
> fn:concat("/data/items/repository/",$myYeardate ,"/")
> let $myShortDate :=
> fn:adjust-date-to-timezone(xs:date($myDate ), ())
> let $targetURI := fn:concat($targetDir,$myShortDate,".xml")
> let $myCollection := ("collection-last",
> fn:concat("collection-",$myShortDate),fn:concat("collection-",
> fn:string-join(fn:tokenize(xs:string($myShortDate),
> "-")[1 to
> 2],"-")),fn:concat("collection-",fn:tokenize(xs:string($myShortDate),
> "-")[1]))
> order by $myDate
> return local:document-move($targetURI,$sourceURI,$myCollection)
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general