Subject: [XQZone General] Links

Mary Holstege mary.holstege at marklogic.com
Mon Jul 18 23:01:50 PDT 2005


Farshad Farzan wrote:
> I created link between two files in two separate directories,
>  import module namespace lnk = "http://marklogic.com/cpf/links" at  
> "/MarkLogic/cpf/links.xqy"
> lnk:create( "/dir1/file1.xml", "/dir2/file2.xml",             "source",  
> "conversion", "strong" )Then , I removed the file1 using webdav  or  
> using xdmp:delete ,I see that file1 is gone but file2 is still there. ,  
> I tried to delete
> the link and the link was not there.. , So it removed the link but not
> the file that was linked to it .!! while the documentation says:
>  The Content Processing Framework will use links to determine if related
> documents should also be removed when a document is deleted from the
> database.

The semantics of the link maintenance has a few subtleties that are
glossed over in the documentation. First, link maintenance only happens
on directories governed by CPF. So if you have a CPF domain on /dir1 but
not on /dir2, for example, link maintenance will not delete files in /dir2.
However, dangling links are not permitted, so the link itself will have
gone with file1.  Second, the direction (which document is "from" and
which is "to"), the strength (only strong links ever cause linked documents
to be removed), and the kind of link (e.g. container) affect whether linked
documents will be removed.  So, if you say file1 is the source of file2
(strong link) and delete file1, then file2 would be removed; but if you
deleted file2 then file1 would not be removed. The source is the "master"
of its product.  Likewise, parts of a "container" will be removed with
the container; resources used by a "consumer" will be removed if their
last consumer is deleted; but a consumer will survive the loss of one of
its resources.

The API for creating links can be a little confusing at first.
This:
   lnk:create( "/dir1/file1.xml", "/dir2/file2.xml",
               "source", "conversion", "strong" )

says: there is a link from /dir1/file1.xml to /dir2/file2.xml where
/dir2/file2.xml is the source of /dir1/file1.xml and /dir1/file1.xml
is the conversion of /dir2/file2.xml and the link is a strong one.

If this seems backwards of how you expect it, draw an arrow:

/dir1/file1 ---------> /dir2/file2

Now, if you label that arrow and put "source" on it:

               source
/dir1/file1 ---------> /dir2/file2

It is quite natural that it is the guy at the end of the
arrow (the $to) that is the source ($rel) of the guy at the tail
of the arrow (the $from). So, deleting /dir2/file2 (the source
of /dir1/file1) will cause /dir1/file1 to be considered for
deletion, but deleting /dir1/file1 (just something we concocted
 from the source file) will not affect /dir2/file2's existence.

Cheers

//Mary


Dr. Mary Holstege
Lead Engineer
Mark Logic Corporation
2000 Alameda de las Pulgas
Suite 100
San Mateo, California  94403
+1 650 655 2336 Phone
mary.holstege at marklogic.com
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.



More information about the General mailing list