It's important to understand that a collection is not a separate,
standalone thing. A collection is simply a list of all the documents
that have been given that collection name. Internally, a collection is
a term list with an entry for each collection name. Each entry is a list
of all documents that have been tagged with that collection name. When
the last document is gone for a particular collection name, that term list
entry is empty and thus that collection no longer exists.
Collection membership(s) is an indexed property of documents. You never
manipulate collections directly.
The function xdmp:collection-delete() does not remove collection
membership from documents. It deletes all documents that belong to
a collection. So, when you called xdmp:collection-delete(‘myBook1’),
it deleted Book1.xml. Book1.xml was a member of both collections.
When it was deleted, it disappeared from both of them. The myBooks1
collection ceased to exist because it became empty. And myBooks2 was
left with one surviving member, Book2.xml.
The same thing would have happened if you'd simply called
fn:document-delete ("Book1.xml")
You should also look at xdmp:document-[add, remove, set]-collections()
On May 20, 2013, at 10:48 AM, [email protected] wrote:
> Hi All,
> I am confused with the behavior of “xdmp:collection-delete($collectionUri)”.
>
> I have following test cases>>>
>
> Let I have 2 xmls “Book1.xml” and “Book2.xml”.
>
> Case-1
> a. I have ingested both the xmls in MarkLogic database in “myBooks1”
> and “myBooks2” collections.
> b. “myBooks1” collection have “Book1.xml”.
> c. “myBooks2” collection have “Book2.xml”.
> d. I executed “xdmp:collection-delete(‘myBook1’)”, then the named
> collection got deleted from the database and Book1.xml is also deleted.
>
> Case-2
> a. I have ingested both the xmls in MarkLogic database in “myBooks1”
> and “myBooks2” collections.
> b. “myBooks1” collection have “Book1.xml”.
> c. “myBooks2” collection have both “Book1.xml” and “Book2.xml”.
> d. Let by mistake , I executed “xdmp:collection-delete(‘myBook1’)”, then
> the named collection got deleted from the database and Book1.xml is also
> deleted.
>
> Now data of “myBook2” collection became inconsistent. Because
> “xdmp:collection-delete(‘myBook1’)” deleted the “Book1.xml” from both the
> collections.
> Why it is so? It should delete the documents which belongs to “myBook1’
> collection only.
>
> Please guide me, whether I am thinking wrongly ?
>
> Thanks,
> Abhinav Kumar Mishra
>
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Tim
> Sent: Saturday, May 18, 2013 7:53 AM
> To: 'MarkLogic Developer Discussion'
> Subject: Re: [MarkLogic Dev General] How can I extract the text within a
> PCDATA element in an XML document?
>
> Thank you!
>
> J Tim
>
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Loren Cahlander
> Sent: Friday, May 17, 2013 9:37 PM
> To: MarkLogic Developer Discussion
> Subject: Re: [MarkLogic Dev General] How can I extract the text within a
> PCDATA element in an XML document?
>
> You can use the XPath expression: /data/comment()
>
> On May 17, 2013, at 8:23 PM, "Tim" <[email protected]> wrote:
>
> Give the following record, how can I extract the text from the comment?
>
> <data error="1" num-seq="20">
> <!-- Warning: Content model for data does not allow PCDATA in unnamed entity
> at line ___ char ___ of file:///___.xml-->
> </data>
>
> Thank you!
>
> Tim Meagher
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
> This e-mail and any files transmitted with it are for the sole use of the
> intended recipient(s) and may contain confidential and privileged
> information. If you are not the intended recipient(s), please reply to the
> sender and destroy all copies of the original message. Any unauthorized
> review, use, disclosure, dissemination, forwarding, printing or copying of
> this email, and/or any action taken in reliance on the contents of this
> e-mail is strictly prohibited and may be unlawful.
> _______________________________________________
> 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