Abstract

This primer provides an introduction to the Linked Data Platform (LDP), with examples illustrating the principal concepts such as the notion of an LDP resource and the LDP container and how they can be used by Web clients. Two sample scenarios show how an LDP client can interact with a LDP server in the context of a read-write Linked Data application i.e. how to use HTTP for accessing, updating, creating and deleting resources from servers that expose their resources as Linked Data.

Status of This Document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.

This is the first draft of LDP Primer Note from the W3C LDP working group.

This document was published by the Linked Data Platform Working Group as a First Public Working Draft. This document is intended to become a W3C Recommendation. If you wish to make comments regarding this document, please send them to public-ldp-comments@w3.org (subscribe, archives). All comments are welcome.

Publication as a First Public Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.

Table of Contents

1. Introduction

The term "Linked Data" [LINKED-DATA] refers to an approach to publishing data that puts linking at the heart of the notion of data, and uses the linking technologies provided by the Web to enable the weaving of a global distributed database. By naming real world entities - be they web resources, physical objects such as the Eiffel Tower, or even more abstract things such as relations or concepts - with http(s) URLs, whose meaning can be determined by dereferencing the document at that URL, and by using the relational framework provided by RDF, data can be published and linked in the same way web pages can. The Linked Data Protocol specifies how web applications can, using the HTTP protocol, find resources and follow links, publish new resources, edit and delete existing ones.

The Primer aims to provide introductory examples and guidance in the use of the LDP protocol, in accordance with best practices [LDP-BP]. For a systematic description of the protocol the reader should consult the normative LDP reference [LDP]. For an overview of the use cases for LDP and the elicited requirements that guided its design, the reader should consult the LDP Use Cases and Requirements [LDP-UCR]; for best practices and guidelines, the reader should consult the LDP Best Practices and Guidelines document [LDP-BP].

Conventions Used in This Document

The examples in this guide are given as a serialization of RDF graphs using the Turtle [turtle] and JSON-LD [json-ld] syntaxes of RDF.

The buttons below can be used to show or hide the available syntaxes.

The JSON-LD examples refer to the following (external) context document:

 
      { 
       "@context":
       {
         "rdf":     "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
         "rdfs":    "http://www.w3.org/2000/01/rdf-schema#",
         "owl":     "http://www.w3.org/2002/07/owl#",
         "ldp":     "http://www.w3.org/ns/ldp#",
         "xsd":     "http://www.w3.org/2001/XMLSchema#",
         "dcterms": "http://purl.org/dc/terms/",
         "foaf":    "http://xmlns.com/foaf/0.1/",
         "wdrs":    "http://www.w3.org/2007/05/powder-s#",
         "bt":      "http://example.org/vocab/bugtracker#"
       }  
      }
  

LDP concepts in a glance

A server hosting Linked Data Platform Resources (LDPRs) may manage two kinds of LDPRs: those resources whose state is represented using RDF (called LDP RDF Sources (LDP-RSs)), and those using other formats (called LDP Non-RDF Sources (LDP-NRs)) such as HTML files, images, other binary files, etc. Resoures respond to retrieval operations using HTTP GET. Often a description conveyed in the response document will describe a specific domain entity; Status, Friendship, Product, Order, Bug, etc. On the other hand, it might contain a description of a number of different concepts. The links contained in the descriptions lead to the subsequent discovery and processing of other resources. Affordances offered by the server make discoverable the forward paths in the application. Together the resources, links and associated affordances together specify what might be termed the API.

Types of LDPRs: LDPR image

The LDP protocol covers read and write interactions with Resources. Writable aspects include creation of new resources (using POST or PUT), updates (using PUT or PATCH), and deletion of resources. Resource creation is an essential feature providing structured creation of resources. Affordances published by the server show that some Resources can be used to create other Resources. This common pattern is often seen in cases where one resource is be made up of a number of others, e.g. a Document Store consists of Documents, a Bug Tracker consists of Bug Reports, a Photo Album consists of Photos, the Net Worth of a person consists of Assets and Liabilities. LDP defines creation for a special kind of Resource called a Container (LDPC), which is able to respond to requests to create new resources, in addition to the general mechanisms HTTP defines. During creation the created resource is added to its Container and a containment link between the Container and the new entry is made.

Therefore a LDPC is a specialization of a LDP-RS representing a collection of links to LDPRs or information resources [WEBARCH] that responds to client requests for creation, modification, and/or enumeration of its linked members and documents. The simplest container is the Basic Container (LDP-BC). It defines the basic containment described using a generic vocabulary. This can be used in a generic storage service to manage a containment hierarchy of arbitrary resources.

..
Fig. 1 Generic document storage using a Basic Container.

Such servers do not impose any restriction on LDPRs and generally act as storage systems without any domain specific application logic and vocabularies. The first scenario in this document concerns a document storage system based on Basic Containers.

A Direct Container is a specialisation of a Basic Container. Additional assertions called membership triples which use a domain-specific vocabulary are made by a Direct Container as part of the creation process. The membership triples augment the containment triples maintained by all containers. For example, one aspect of a Product inventory system concerns the how a Direct Container is used for the management of a Product portfolio, where use of existing vocabularly is preferable.

..
Fig. 2 Using domain vocabularly with a Direct container.

Direct Container membership triples can be about subjects other than the Container resource. An example is a Photo management application where a Photo Container is used for the management of Photos, and where membership triples then express the relationship between a User and a Photo.

..
Fig. 3 Membership triples with a non-Container subject.

Another common pattern is where different facets of a Resource be managed using multiple Containers. For example, a Bug Report is has an associated list of Comments as well as supportive media resources.

..
Fig. 4 Managing multiple facets of a Bug with two Direct Containers.

One important usage concerns using LDP to expose the data and services of existing applications. These systems impose restrictions on LDPRs since the LDP interactions should consider the constraints of the underlying business logic and data model. The bug tracker example presented in the latter part of this primer is an example of an application specific LDP server.

Note

Formal definitions of the terms LDPR, LDPC, and other concepts introduced by LDP can be found in the 'Terminology' section of the Linked Data Platform 1.0 specification [LDP]

The following provide a set of examples to show the Linked Data Platform interactions. Note, this is a primer and should not be considered as a canonical example of ideal LDP modeling.

2. Online document store example (LDP Basics)

This section provides a set of examples of using an online document store application. These examples will demonstrate the behaviour of both types of LDPRs and LDP Basic Containers. Registration with the online document store application by a user results in some data storage space (a root Basic Container) where the application's web resources are stored. Using this root Basic Container a user can create new documents and also child containers to further organize her documents stored in this application.

APIs of web applications are commonly documented by listing valid operations which can operate on URLs, where the URLs are described as templates. A description of our exemplary LDP based document store is in the following table. We note with emphasis that it is important for servers to use links as the main mechanism to reveal the location of resources. If it would be necessary to encode such templates into client applications, this would be a strong indicator that the design breaches a number of good design principles.

Path Method Description
/{username}/ GET Lists all the documents in the root container.
POST Create a new document under the root container.
PUT Update the description and/or list of files of the root container.
PATCH Update the description and/or list of files of the root container.
DELETE Not allowed.
/{username}/{{document}/}*
GET Retrieve the document.
POST Discovered from the resource affordances.
PUT Update the document.
PATCH Partial update to the document if PATCH is supported.
DELETE Delete the document.
/*/*
OPTIONS Discover the allowed operations over a resource
HEAD Only retrieve meta-information about a resource

In this example, we will see how Alice, a user of this system, does read / write management of documents using the LDP protocol. A typical interaction with the system would start with Alice registering as a user. It is likely that registration would be a LDP based interaction, but this aspect is out of scope of this example. A consequence of the registration is allocation of space for the storage of documents, and communication of this URL to the user, e.g. a basic container at http://example.org/alice/. This section describes a typical flow of interactions where Alice firsts reads the root document and discovers its affordances. This is followed by subsequent examples of creation, update and delete, and finishes with how the client is able to create nested structure from the containers.

2.1 Looking up a basic container (GET on an LDP-BC)

First Alice looks up her storage by retrieving the LDP Basic Container assigned to her to hold her documents. Alice's LDP client does this by doing a GET request on the URI, http://example.org/alice/.

Example 1: Request - basic container retrieval
Turtle:
GET /alice/ HTTP/1.1
Host: example.org
Accept: text/turtle

As her document storage was just created, it is an empty container.

Example 2: Response - basic container retrieval
Turtle:
HTTP/1.1 200 OK 
Content-Type: text/turtle; charset=UTF-8
Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel='type', <http://www.w3.org/ns/ldp#Resource>; rel='type'
Allow: OPTIONS,HEAD,GET,POST,PUT,PATCH
Content-Length: 250
ETag: W/'123456789'
	
@prefix dcterms: <http://purl.org/dc/terms/>.
@prefix ldp: <http://www.w3.org/ns/ldp#>.
	
<http://example.org/alice/> a ldp:Container, ldp:BasicContainer;
  dcterms:title 'Alice’s data storage on the Web' .		

As shown in the example, in addition to the RDF representation of the Basic Container using the requested media type the server provides an etag of the resource representation and Link headers advertising that the requested resource is indeed an LDP Basic Container and it will support the LDP interaction model.

In addition, the response also contains "Allow" header which advertises which HTTP operations are supported by this LDP Basic Container resource. In this example, it supports OPTIONS,HEAD,GET,POST,PUT,PATCH HTTP verbs.

Note

The Linked Data Platform 1.0 specification [LDP] says that all LDP servers MUST support the Turtle media type for LDP-RS resources and SHOULD support JSON-LD media type.

2.2 Discovering the affordances (OPTIONS on an LDP-BC)

In the previous example, we saw that Alice can discover what operations are allowed on a resource by doing a GET request on the resource. As an alternative, she can use the OPTIONS operation to learn of the permitted operations on any given resource.

Example 3: Request - retreiving OPTIONS of a basic container
OPTIONS /alice/ HTTP/1.1
Host: example.org      
Example 4: Response - retreiving OPTIONS of a basic container
HTTP/1.1 204 OK
Allow: OPTIONS,HEAD,GET,POST,PUT,PATCH
Accept-Post: text/turtle, application/ld+json, image/bmp, image/jpeg
Accept-Patch: example/patch
Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel='type'     

According to the response, HTTP operations {OPTIONS,HEAD, GET,POST,PUT,PATCH} are allowed on her root container. In addition to the allowed operations, Accept-Post and Accept-Patch provides which media types are supported by the respective operations. The rel="type" Link header advertises that this resource supports LDP protocol and it is an LDP Basic Container.

In this case, the response tells Alice's LDP client that this is an LDP-Basic Container and the container allows her to POST things of both RDF types (text/turtle, application/ld+json) and images (image/bmp and image/jpeg).

2.3 Creating a RDF resource (POST an RDF resource to an LDP-BC)

Alice can upload a social profile document to her store, by POSTing her FOAF personal profile document to her LDP-BC at the root of her document store. Note, the Slug header offers the server a hint about URL of the resource to be created.

The FOAF document includes statements about the resource to be created and other resources relative to the resource to be created. According the LDP specification Alice can use null relative URI (<>) in the request entity body to refer to resource to be created.

Example 5: Request - creating a RDF resource
Turtle:
POST /alice/ HTTP/1.1
Host: example.org
Slug: foaf
Content-Type: text/turtle

@prefix dc: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

<> a foaf:PersonalProfileDocument;
    foaf:primaryTopic <#me> ;
    dc:title 'Alice’s FOAF file' .

<#me> a foaf:Person;
    foaf:name 'Alice Smith'  .    

Example 6: Response - creating a RDF resource
HTTP/1.1 201 Created
Location: http://example.org/alice/foaf
Link: <http://www.w3.org/ns/ldp#Resource>; rel='type'
Content-Length: 0 

The response to the create request provides a Link to the newly created resource using the Location header. In this case, the server has honored the hint provided by the slug header and created the new resource in the URL http://example.org/alice/foaf.

Knowing the URL of the newly created resource, Alice can check the container again to confirm that the container correctly contains the newly created resource.

Example 7: Request - basic container retrieval after resource created
GET /alice/ HTTP/1.1
Host: example.org
Accept: text/turtle, application/ld+json
Example 8: Response - basic container retrieval after resource created
Turtle:
HTTP/1.1 200 OK 
Content-Type: text/turtle; charset=UTF-8
Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel='type'
Allow: OPTIONS,HEAD,GET,POST,PUT,PATCH
Content- Length: 245
ETag: W/'123456789'
  
@prefix dcterms: <http://purl.org/dc/terms/>.
@prefix ldp: <http://www.w3.org/ns/ldp#>.
  
<http://example.org/alice/> a ldp:Container, ldp:BasicContainer;
   dcterms:title 'Alice’s data storage on the Web' ;
   ldp:contains <http://example.org/alice/foaf> . 

2.4 Creating a non-RDF (binary) resource (POST an image to an LDP-BC)

Next, Alice wants to upload a photo of herself to the document storage. She can create an image by POSTing it in the same way she created the RDF document.

Example 9: Request - creating a non-RDF resource
POST /alice/ HTTP/1.1
Host: example.org
Slug: avatar
Link: <http://www.w3.org/ns/ldp#Resource>; rel="type"
Content-Type: image/png
Content- Length: 1020

### binary data ###
Example 10: Response - creating a non-RDF resource
HTTP/1.1 201 Created
Location: http://example.org/alice/avatar
Link: <http://www.w3.org/ns/ldp#Resource>; rel="type"
Link: <http://example.org/alice/avatar/meta>; rel="describedby"
Content-Length: 0   

The outcome of creating a non-RDF is similar to creating a RDF resource. If successful, the server will return a 201 success code with a Location header that points to the created resource. Furthermore, in the case of binary resources the server may create an additional file to maintain the metadata about the binary file. In the above example, the server creates a new LDP-RS to maintain metadata about the binary resource such as creation date, owner, etc. and this metadata resource is advertised using a Link header with the relation "describedby".

Similar to creating a RDF resource (LDP-RS), a containment triple will be added to the container when a non-RDF (LDP-NR) is created. Thus, the representation of the LDP container after creating the image looks like the following.

Example 11: Container representation after the non-RDF resource creation
Turtle:
@prefix dcterms: <http://purl.org/dc/terms/>.
@prefix ldp: <http://www.w3.org/ns/ldp#>.
  
<http://example.org/alice/> a ldp:Container, ldp:BasicContainer;
   dcterms:title 'Alice’s data storage on the Web' ;
   ldp:contains <http://example.org/alice/foaf> , <http://example.org/alice/avatar> . 

2.5 Update a RDF LDP resource (PUT on an LDP-RS)

After creating the image as shown in the previous example, Alice now wants to update her FOAF profile with a link to the image. After retrieving her FOAF profile using a HTTP GET operation, she uses HTTP PUT to update the document by amending the RDF with a link to her photo.

In this example, Alice's LDP client sends the E-tag of the resource representation that it retrieved previously to prevent any lost update problems.

Example 12: Request - updating a RDF resource
Turtle:
PUT /alice/foaf HTTP/1.1
Host: example.org
If-Match: W/"123454321"
Content-Type: text/turtle

@prefix dc: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

<> a foaf:PersonalProfileDocument;
    foaf:primaryTopic <#me> ;
    dc:title "Alice’s FOAF file" .

<#me> a foaf:Person;
    foaf:name "Alice Smith"  ;
    foaf:img <http://example.org/alice/avatar> .
      
Example 13: Response - updating a RDF resource
HTTP/1.1 204 No Content 
Link: <http://www.w3.org/ns/ldp#Resource>; rel="type" 

If the operation is successful as shown above, the document will be updated with new information.

Note

Alice can also use the PATCH operation to update the resource.

2.6 Deleting a resource (DELETE on an LDPR)

If Alice decides to delete the image, she can do that with a delete operation.

Similar to the previous update operation, Alice uses the etag of the resource representation she retrieved with If-Match header to do a conditional delete to ensure that the resource state was not changed since she decided to delete it.

Example 14: Request - deleting a RDF resource
DELETE /alice/avatar HTTP/1.1
Host: example.org
If-Match: W/"123454322"        
Example 15: Response - deleting a RDF resource
HTTP/1.1 204 No Content 

As well as deleting the resource, the server removes the containment triple from the container. For example, a subsequent GET request on the container will return a graph isomorphic to the one shown in the following representation::

Example 16: Container representation after resource deletion
Turtle:
@prefix dcterms: <http://purl.org/dc/terms/>.
@prefix ldp: <http://www.w3.org/ns/ldp#>.
  
<http://example.org/alice/> a ldp:Container, ldp:BasicContainer;
   dcterms:title 'Alice’s data storage on the Web' ;
   ldp:contains <http://example.org/alice/foaf> . 

For any subsequent request on the deleted resource, the server will respond with the appropriate HTTP response code.

Example 17: Request - after deletion
GET /alice/avatar HTTP/1.1
Host: example.org
Accept: image/png
Example 18: Response - after deletion
HTTP/1.1 410 Gone 

2.7 Structural Manipulation (Child Containers)

In order for the client to introduce hierarchy to the management of documents, the document store allows creation of documents which are containers. That enables Alice to create a container hierarchy to organise her documents. This can be done by POSTing (a child) container representation to a (parent) container. This enables Alice to create a child container which she intends to use for image storage.

..
Fig. 5 Child Containers inside a Basic Container.
Example 19: State of Alice's document store before creating the photo (child) container
Turtle:
@prefix ldp: <http://www.w3.org/ns/ldp#> .
@prefix dcterms: <http://purl.org/dc/terms/> .

<http://example.org/alice/> a ldp:Container, ldp:BasicContainer ;
    dcterms:title "Alice’s data storage on the Web" ;
    ldp:contains <http://example.org/alice/foaf> .
    

To create a new container for managing photos, Alice POSTs a representation of a container (LDP-BC) to the root container. Alice express her intention that the newly created resource should be an LDP Basic Container by including a Link header in the request with the relationship 'type'.

Example 20: Request - creating a new container
Turtle:
POST alice/ HTTP/1.1
Host: example.org
Content-Type: text/turtle
Link: <http://www.w3.org/ns/ldp/BasicContainer>; rel='type'
Slug: photos

@prefix ldp: <http://www.w3.org/ns/ldp#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
 
<> a ldp:Container, ldp:BasicContainer;
   dcterms:title "Photos of Alice" ; 
   dcterms:description "This container will contain photos of Alice." .  
   

If the create is successful, the server responds with location of the newly created container for the photos.

Example 21: Response - creating the new container
HTTP/1.1 201 Created
Location: http://example.org/alice/photos/
Content-Length: 0  

After creation of this new container, the parent container will look like

Example 22: State of Alice's document store after creating the photo (child) container
Turtle:
@prefix ldp: <http://www.w3.org/ns/ldp#> .
@prefix dcterms: <http://purl.org/dc/terms/> .

<http://example.org/alice/> a ldp:Container, ldp:BasicContainer ;
    dcterms:title "Alice’s data storage on the Web";
    ldp:contains <http://example.org/alice/foaf> , <http://example.org/alice/photos/> .
    

and the photo container will look like the following.

Example 23: State of Alice's newly created photo container
Turtle:
@prefix ldp: <http://www.w3.org/ns/ldp#> .
@prefix dcterms: <http://purl.org/dc/terms/> .

<http://example.org/alice/photos/> a ldp:Container, ldp:BasicContainer;
  dcterms:title "Photos of Alice" ;
  dcterms:description "This container will contain photos of Alice." .  
   

3. Bug Tracker Example (LDP Direct containers)

The previous section provided practical examples of basic LDP interactions using LDP Basic Containers. One of the limitations of LDP Basic Containers is that a fixed LDP vocabulary is used to assert the relations between a container and its contained resources. However, some scenarios require domain specific vocabulary to be used to list the members of a container. For example, an application which already used Linked Data and its own vocabulary may like to continue using the same vocabulary when migrating to LDP protocol. LDP Direct containers introduce the concept of membership triples allowing the flexibility to define the form of the membership. One of these flexibility points is the ability to select the predicate of the membership triple which can be from a domain-specific vocabulary. This is done using the ldp:hasMemberRelation or ldp:isMemberOfRelation predicate of the Direct Containers.

In addition, in some scenarios it is necessary to add relationships between the newly created resource and some other resource (which is not necessarily the container or another document / information resource). This allows to define relationship between any other information resource or non-information resource (real world thing) by defining the membership constant subject or the object URI of the membership triples using ldp:membershipResource predicate of the Direct Container. The usage of the ldp:hasMemberRelation predicate as well as the ldp:membershipResource will be explained in the following examples.

Note

For more information on information resources (documents) vs real world entities (things) separation please refer to Web Arch (Section 2.2. URI/Resource Relationships) , , Cool URIs (Section 3. URIs for Real-World Objects), URLs in Data (Section 3. Landing Pages and Records).

The examples in this section will revolve around a very simple Bug Tracker application. Bug Tracker application records the bugs of several products allowing reporting, updating and deleting bugs and products. In contrast to the online document store example, the bug tracker wants to use an existing domain vocabulary, e.g. has_bug, to express membership relationships in the containers. LDP provides the additional interaction capability in the protocol to add the domain specific triples based on the properties defined in the LDP Direct Container.

A RESTful API for a simple Bug Tracker system might be described as follows.

Path Method Description
/tracker/{product-id}/
GET Lists the product description and bug reports associated with a product.
POST Create a new bug report associated with a product.
PUT Update the project description.
PATCH Not supported.
DELETE Delete the project description and associated bug reports.
/tracker/{product-id}/{bug-id}
GET Gets the bug report.
POST Not supported.
PUT Update the bug report.
PATCH Not supported.
DELETE Delete the bug report.
/tracker/*/*
OPTIONS Discover the allowed operations over a resource
HEAD Only retrieve meta information about a resource

In the examples in this section, we will only focus on the container representation, creation and deletion of resources because that is where the Basic Containers, Direct Containers, and Indirect Containers differ. Other operations such as updating a resource would be similar to what was illustrated in the previous example.

3.2 Creation (POST a resource to an LDP-DC)

Continuing from the previous example, we can report a Bug against the "LDP Demo" product by creating a Bug report (an LDPR representing the bug) under the "LDP Demo" product description LDPC by posting a RDF representation of the Bug report to the LDPC associated with the product description.

The bug report document includes statements about the resource to be created. According the LDP specification, a client can use null relative URI (<>) in the request entity body to refer to resource to be created.

Example 26: A request for creating a bug
Turtle:
POST /tracker/ldp-demo/ HTTP/1.1
Host: example.org
Content-Type: text/turtle
Link: <http://www.w3.org/ns/ldp#Resource>; rel="type"

@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix bt: <http://example.org/vocab/bugtracker#> .
 
<> a bt:BugReport;
  dcterms:title "LDP Demo crashes when shutting down.";
  dcterms:creator <http://example.org/tracker/users/johndoe> . 
     
JSON-LD:
POST /tracker/ldp-demo/ HTTP/1.1
Host: example.org
Content-Type: application/ld+json
Link: <http://www.w3.org/ns/ldp#Resource>; rel="type"

{
  "@context": "https://dvcs.w3.org/hg/ldpwg/raw-file/default/ldp-primer/context.json",
  "@id": "",
  "@type": "bt:BugReport",
  "dcterms:title": "LDP Demo crashes when shutting down.",
  "dcterms:creator": { "@id": "http://example.org/tracker/users/johndoe" }
}

If the creation is successful, the server responds with location of the newly created resource.

Example 27: A response of creating new a bug
HTTP/1.1 201 Created
Location: http://example.org/tracker/ldp-demo/bug67
Content-Length: 0           

If the creation fails, the server will respond with an appropriate status code depending on the error. If successful, the LDP Demo product description LDPC will have the following representation after the creation of new resource.

Example 28: The state of the product LDPC after the bug creation
Turtle:
@prefix ldp: <http://www.w3.org/ns/ldp#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix bt: <http://example.org/vocab/bugtracker#> .

</tracker/ldp-demo/> ldp:DirectContainer;
  ldp:membershipResource </tracker/ldp-demo/#it>;
  ldp:hasMemberRelation bt:hasBug;
  dcterms:title "Product description of LDP Demo product which is also an LDP-DC";
  ldp:contains <bug3>, <bug4> , <bug67> .
  
</tracker/ldp-demo/#it> a bt:Product;
  dcterms:title "LDP Demo";
  bt:hasbug <bug3>, <bug4>, <bug67> .
	
JSON-LD:
{
  "@id": "/tracker/ldp-demo/",
  "@type": [ "ldp:DirectContainer", "bt#Product"],
  "@context": "https://dvcs.w3.org/hg/ldpwg/raw-file/default/ldp-primer/context.json",
  "dc:title": "Product description of LDP Demo product which is also an LDP-DC",
  "ldp:contains": [{ "@id": "/tracker/ldp-demo/bug3"}, { "@id": "/tracker/ldp-demo/bug4"}, { "@id": "/tracker/ldp-demo/bug67"}],
  "ldp:hasMemberRelation": "bt:hasbug",
  "ldp:membershipResource": { "@id": "/tracker/ldp-demo/#it"}
}
{
  "@id": "/tracker/ldp-demo/#it",
  "@type": "bt:Product",
  "dc:title": "LDP Demo",
  "bt:hasbug": [{ "@id": "/tracker/ldp-demo/bug3"}, { "@id": "/tracker/ldp-demo/bug4"}, { "@id": "/tracker/ldp-demo/bug67"} ]
}

As you can see two new triples are added to the container. That is (</tracker/ldp-demo/>, <ldp:contains>, </tracker/ldp-demo/bug67>) and (</tracker/ldp-demo/#it>, <bt:hasbug>, </tracker/ldp-demo/bug67>). The former is added in any type of container and the latter is defined by the direct container properties.

The created Bug resource will have the following representation. Note that server has added a server managed property, creation date (dcterms:created), and a default value for the state (bt:isInState) to the Bug in addition to what was POSTed.

Example 29: The state of the bug LDPR
Turtle:
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix bt: <http://example.org/vocab/bugtracker#> .

</tracker/ldp-demo/bug67> a bt:Bug;
  dcterms:title "Product A crashes when shutting down.";
  dcterms:creator </tracker/users/johndoe>;
  dcterms:created "2013-05-05T10:00"^^xsd:dateTime;
  bt:isInState "New" .
     
JSON-LD:
{
  "@context": "https://dvcs.w3.org/hg/ldpwg/raw-file/default/ldp-primer/context.json",
  "@id": "/tracker/ldp-demo/bug67",
  "dcterms:title": "Product A crashes when shutting down.",
  "dcterms:creator": { "@id": "/tracker/users/johndoe" },
  "dcterms:created": {
    "@type": "http://www.w3.org/2001/XMLSchema#dateTime",
    "@value": "2013-05-05T10:00:00"
  },
  "bt:isInState": "New"
}

3.3 Deletion (DELETE on an LDPR associated with an LDP-DC)

This example illustrates the behaviour of a Direct Container when a resource is deleted.
Example 30
DELETE /tracker/ldp-demo/bug3 HTTP/1.1 
Host: example.org
If-Match: W/"123454322"

If the delete is successful, the server will respond with a success status code.

Example 31
HTTP/1.1 204 No Content

After the deletion, the representation of the container will look like the following

Example 32: The state of the product LDPC after the bug deletion
Turtle:
@prefix ldp: <http://www.w3.org/ns/ldp#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix bt: <http://example.org/vocab/bugtracker#> .

</tracker/ldp-demo/> a ldp:DirectContainer;
  ldp:membershipResource </tracker/ldp-demo/#it>;
  ldp:hasMemberRelation bt:hasBug;
  dcterms:title "Product description of LDP Demo product which is also an LDP-DC";
  ldp:contains <bug4> , <bug67> .
  
</tracker/ldp-demo/#it> a bt:Product;
  dcterms:title "LDP Demo";
  bt:hasBug <bug4>, <bug67> .
	
JSON-LD:
{
  "@id": "/tracker/ldp-demo/",
  "@type": [ "ldp:DirectContainer", "bt:Product"],
  "@context": "https://dvcs.w3.org/hg/ldpwg/raw-file/default/ldp-primer/context.json",
  "dc:title": "Product A",
  "ldp:contains": [{ "@id": "/tracker/ldp-demo/bug4"}, { "@id": "/tracker/ldp-demo/bug67"}],
  "ldp:hasMemberRelation": "bt:hasBug",
  "ldp:membershipResource": "#it"
}
{
  "@id": "#it",
  "@type": "bt:Product",
  "bt:hasBug": [{ "@id": "/tracker/ldp-demo/bug4"}, { "@id": "/tracker/ldp-demo/bug67"} ]
}


As seen from the LDP Direct Container representation above, both the containment triple (</tracker/ldp-demo/>, ldp:contains, </tracker/ldp-demo/bug3>) and the membership triple (</tracker/ldp-demo/#it>, bt:hasBug, </tracker/ldp-demo/bug3>) were removed from the container representation.

4. Extended Bug Tracker Example (LDP Indirect containers)

In this next example, we will use the same scenario as in the previous example, but change the container type to a LDP Indirect Container to show the differences between LDP Direct Containers and Indirect Containers and when to use LDP Indirect Containers. Though LDP Direct Containers provide the flexibility to define the constant membership URI (the subject of the membership triple when using ldp:hasMemberRelation or the object of the membership triple when using ldp:isMemberOfRelation) and the membership predicate, when creating members the member derived URI is always the newly created document URL. LDP Indirect containers provide more flexibility by allowing the member derived URI to be any resource; it could be either a non-information resource or a document other than the newly created resource. This done by defining the predicate to look for in the representation of the resource to be created by setting the ldp:insertedContentRelation predicate of the LDP Indirect Container. How this done will be explained in the following examples.

4.2 Creation (POST a resource to an LDP-IC)

Continuing from the previous example, we can create a new Bug Report against the 'LDP demo' product by creating a Bug Report LDPR under the 'LDP Demo' product description LDPC.

The client POSTs a representation of a Bug Report to the Bug Tracker LDPC.

Example 35: A request for creating a bug
Turtle:
POST /tracker/ldp-demo/ HTTP/1.1
Host: example.org
Content-Type: text/turtle

@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix bt: <http://example.org/vocab/bugtracker#> .
 
<> a bt:BugReport;
   foaf:primaryTopic <#it>;
   dcterms:title "Product A crashes when shutting down.";
   dcterms:creator </tracker/ldp-demo/johndoe> .
     
<#it> a bt:Bug .     
     
JSON-LD:
POST /tracker/ldp-demo/ HTTP/1.1
Host: example.org
Content-Type: application/ld+json

{
  "@context": "https://dvcs.w3.org/hg/ldpwg/raw-file/default/ldp-primer/context.json",
  "@id": "",
  "@type": "bt:BugReport",
  "foaf:primaryTopic": { "@id": "#it" },
  "dcterms:title": "Product A crashes when shutting down.",
  "dcterms:creator": { "@id": "/tracker/ldp-demo/johndoe" }
}
{
    "@id": "#it",
    "@type": "bt:Bug"
}

One thing to note is that the representation of the resource to be created contains a triple (< >, foaf:primaryTopic , <#it>). If the create request is successful, the server responds with location of the newly created resource.

Example 36: A response of creating new a bug
HTTP/1.1 201 Created
Location: http://example.org/tracker/ldp-demo/bug67
Content-Length: 0           

If the creation fails, the server will respond with an appropriate status code depending on the error. After the resource is creation, the Product A LDPC will have the following representation.

Example 37: The state of the product LDPC after the bug creation
Turtle:
@prefix ldp: <http://www.w3.org/ns/ldp#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix bt: <http://example.org/vocab/bugtracker#> .

</tracker/ldp-demo/> ldp:IndirectContainer;
  ldp:membershipResource </tracker/ldp-demo/#it>;
  ldp:hasMemberRelation bt:hasBug;
  dcterms:title "Product description of LDP Demo product which is also an LDP-IC";
  ldp:contains <bug3>, <bug4> , <bug67> .
  
<#it> a bt:Product;
  dcterms:title "LDP Demo";
  bt:hasBug <bug3#it>, <bug4#it>, <bug67#it> .
	
JSON-LD:
{
  "@id": "/tracker/ldp-demo/",
  "@type": [ "ldp:IndirectContainer", "bt:Product"],
  "@context": "https://dvcs.w3.org/hg/ldpwg/raw-file/default/ldp-primer/context.json",
  "dc:title": "Product description of LDP Demo product which is also an LDP-IC",
  "ldp:contains": [{ "@id": "/tracker/ldp-demo/bug3"}, { "@id": "/tracker/ldp-demo/bug3"}, { "@id": "/tracker/ldp-demo/bug67"}],
  "ldp:hasMemberRelation": "bt:hasBug",
  "ldp:membershipResource": "#it"
}
{
    "@id": "/tracker/ldp-demo/#it",
    "@type": "bt:Product",
    "dc:title": "LDP Demo"
    "bt:hasBug": [{ "@id": "/tracker/ldp-demo/bug3#it"}, { "@id": "/tracker/ldp-demo/bug3#it"}, { "@id": "/tracker/ldp-demo/bug67#it"} ]
}

As you can see, two new triples are added to the container. That is (</tracker/ldp-demo/>, <ldp:contains>, </tracker/ldp-demo/bug67>) and (</tracker/ldp-demo/#it>, <bt:hasbug>, </tracker/ldp-demo/bug67#it>).

5. Security

It is not the focus of the Linked Data Platform WG to provide security mechanisms for read/write Linked Data applications; since LDP builds on HTTP, it can re-use any mechanism defined for HTTP. Though most of the security mechanisms that are applicable to general web applications are equally applicable to Linked Data applications, there is still some space to build security mechanisms specific to Linked Data applications by leveraging the Linked Data technologies and providing concrete security requirements for Linked Data applications. In this context, LDP WG has started to create a WG note on Access Control which aims to produce use cases for security scenarios of LDP applications that can be used as the input to a later initiative that will be focused on developing standard security mechanisms for LDP applications.

6. LDP Implementations

A list of implementations that plan to be LDP compliant is available in the LDP Implementations wiki page. The Linked Data Platform 1.0 - Implementation Reports provide the coverage of the specification by each LDP implementation.

A. Acknowledgements

Many thanks to John Arwe (IBM), Ashok Malhotra (Oracle), and Henry Story (Apache Software Foundation) for their thorough review on the LDP Primer document and proposed corrections. We also like to thank all members of the Linked Data Platform WG for the valuable feedback.

B. Change History

This section is non-normative.

The change history is up to the editors to insert a brief summary of changes, ordered by most recent changes first and with heading from which public draft it has been changed from.

C. References

C.1 Informative references

[LDP]
Steve Speicher; John Arwe; Ashok Malhotra. Linked Data Platform 1.0. 11 March 2014. W3C Last Call Working Draft. URL: http://www.w3.org/TR/ldp/
[LDP-BP]
Cody Burleson; Miguel Esteban Gutiérrez; Nandana Mihindukulasooriya. LDP Best Practices and Guidelines. W3C Working Draft. URL: http://www.w3.org/2012/ldp/hg/ldp-bp/ldp-bp.html
[LDP-TESTS]
Raúl García-Castro; Fernando Serena. Linked Data Platform 1.0 Test Cases. W3C Working Draft. URL: http://www.w3.org/2012/ldp/hg/tests/ldp-testsuite.html
[LDP-UCR]
Steve Battle; Steve Speicher. Linked Data Platform Use Cases and Requirements. 13 March 2014. W3C Note. URL: http://www.w3.org/TR/ldp-ucr/
[LINKED-DATA]
Tim Berners-Lee. Linked Data Design Issues. 27 July 2006. W3C-Internal Document. URL: http://www.w3.org/DesignIssues/LinkedData.html
[WEBARCH]
Ian Jacobs; Norman Walsh. Architecture of the World Wide Web, Volume One. 15 December 2004. W3C Recommendation. URL: http://www.w3.org/TR/webarch/
[json-ld]
Manu Sporny; Gregg Kellogg; Markus Lanthaler. JSON-LD 1.0. 16 January 2014. W3C Recommendation. URL: http://www.w3.org/TR/json-ld/
[turtle]
Eric Prud'hommeaux; Gavin Carothers. RDF 1.1 Turtle. 25 February 2014. W3C Recommendation. URL: http://www.w3.org/TR/turtle/