Closed noorbakerally closed 5 years ago
Carbon LDP uses ldp:contains
to indicate a direct containment relation. In other words, a parent/child relation. So only the parent container will be able to have an ldp:contains
triple to one of its children. You can see that relation as a hard or hierarchical link between the tree of documents you create.
That is why the ldp:member
(or whatever membership predicate you configure with ldp:hasMemberRelation
) exists. Unlike ldp:contains
, the membership triple represents a
soft non hierarchical link, and therefore, multiple containers can have membership triples to the same document.
I would advise you to (almost always) use the membership relation instead of the containment relation (unless you want to follow the structure of the tree).
The membership relation gets added every time you create an ldp:RDFSource
on a container and you can add that ldp:RDFSource
as a member of another container in two ways:
If you are using the JS SDK you would only need to execute the following code:
appContext.documents.addMember( "--ContainerBIRI--", "http://example.com/A/r1" ).then(
() => {
// Member added to the second container
}
)
If you are using the REST API, after creating <http://example.com/A/r1>
you can send the following PUT request to container B:
PUT --containerBIRI--
Accept: text/turtle
Content-Type: text/turtle
Prefer: http://www.w3.org/ns/ldp#Container; rel=interaction-model
Authorization: Basic ------YOUR BASIC AUTH BASE64------
PREFIX c: <https://carbonldp.com/ns/v1/platform#>
[
a c:AddMemberAction;
c:targetMember <http://example.com/A/r1>
].
After sending that request you should receive a 200 OK
and you should see the membership triples added on container B.
Note: c:targetMember
can point to several members to add them all at once.
Closing due to inactivity.
Suppose an LDP-RS r1 is created in container A with http://example.com/A/r1. Is it possible to add r1 to a different container say Container B with posting r1 to B. In short, is it possible to add r1 to the containment triples in B so that the content of B has the triple
<ContainerBIRI> ldp:contains <http://example.com/A/r1>
?