Let's start with an example of how to create a simple resource (say LDP RDF Source). You need to know a URL that accepts
POST
of the media type you want. Here's the
POST
request:1: POST /netWorth/nw1/liabilities/ HTTP/1.1
2: Host: example.org
3: Accept: text/turtle
4: Content-Type: text/turtle
5: Content-Length: 63
6:
7: @prefix dcterms: <http://purl.org/dc/terms/>.
8: @prefix o: <http://example.org/ontology>.
9:
10: <> a <http://example.org/ontology#Liability>;
11: dcterms:title "Home loan";
12: o:value 200000.00 .
13: # plus any other properties that the domain says liabilities have
(Example "borrowed" from LDP spec example)
s Very simple, just
POST
some Turtle to a URL.Now let's look at what it would look like to create a Container:
1: POST /netWorth/nw1/liabilities/ HTTP/1.1
2: Host: example.org
3: Accept: text/turtle
4: Content-Type: text/turtle
5: Content-Length: 72
6: Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel="type"
7:
8: @prefix dcterms: <http://purl.org/dc/terms/>.
9: @prefix o: <http://example.org/ontology>.
10:
11: <> a <http://www.w3.org/ns/ldp#BasicContainer> ;
12: dcterms:title "Home loans" ;
13: o:limit 500000.00 .
14: # plus any other properties
That's it, just
POST
ing some content just like before. I added a Link
header (line #6) on the POST
request to be explicitly clear that I want this newly created resource to behave as an ldp:BasicContainer
. Note that I wanted to be expressive so I included the type triple on line 11, though the spec doesn't require this as the Link header as the spec-defined way to clearly assign the desired behavior.
There are various other ways that
ldp:Container
s can come into existence, most of those reasons are dependent on the server's application-specific rules. For example, an application might allow the creation of a resource of say "Customer", the application logic may determine to create a number of supporting Containers for the new Customer resource, such as which assets and liabilities they have.