Selva
Selva

Reputation: 237

what happens if i don't specify the collection name in Corb

I have a corb script to run node replace on the xml files.

If I don't specify the collection, will it remove the documents from the existing collections?

Upvotes: 3

Views: 80

Answers (2)

Selva
Selva

Reputation: 237

Its better to provide an empty collection value, while doing the node-replace so it doesn't alter the existing collections of the document. Not defining this attribute is throwing errors while running the script.

Upvotes: 0

Mads Hansen
Mads Hansen

Reputation: 66781

If you are altering the document with xdmp:node-replace(), then the document will remain in it's collections and you do not need to worry about setting/adding it back.

If you are using xdmp:document-insert() to replace the document at the current URI, then you do need to specify the collection(s), otherwise it will be removed from the existing collections.

However, you can use xdmp:document-get-collections() to retrieve the sequence of collections for the URI and use it for the 4th parameter of xdmp:document-insert()

xdmp:document-insert($URI, $doc, (), xdmp:document-get-collections($URI))

Upvotes: 2

Related Questions