Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Learning W3C Linked Data Platform with examples

4,870 views

Published on

The W3C Linked Data Platform (LDP) specification describes a set of best practices and simple approach for a read-write Linked Data architecture, based on HTTP access to web resources that describe their state using the RDF data model. This presentation provides a set of simple examples that illustrates how an LDP client can interact with an LDP server in the context of a read-write Linked Data application i.e. how to use the LDP protocol for retrieving, updating, creating and deleting Linked Data resources.

Published in: Technology
  • Be the first to comment

Learning W3C Linked Data Platform with examples

  1. 1. Center for Open Middleware Learning W3C Linked Data Platform 1.0 with examples Nandana Mihindukulasooriya, Center for Open Middleware / Ontology Engineering Group Universidad Politécnica de Madrid, Spain. @nandanamihindu / nmihindu@fi.upm.es
  2. 2. Center for Open Middleware License 2 • This work is licensed under a Creative Commons Attribution- ShareAlike 4.0 International License. • You are free to: • Share — copy and redistribute the material in any medium or format • Adapt — remix, transform, and build upon the material for any purpose, even commercially. • Under the following terms: • Attribution — You must attribute by including a credits text stating • 'The slides are particially based on "Learning W3C Linked Data Platform 1.0 with examples" by Nandana Mihindulasooriya, Ontology Engineering Group' • ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
  3. 3. Center for Open Middleware Agenda 3 • Introduction • Examples • Looking up a Linked Data resource • Modifying a Linked Data resource • Creating Linked Data resources • Deleting a Linked Data resource • Managing non-RDF resources
  4. 4. Center for Open Middleware Learning W3C Linked Data Platform 1.0 with examples INTRODUCTION 4
  5. 5. Center for Open Middleware Back to the basics … 5 “Linked Data principles • Use URIs as names for things • Use HTTP URIs so that people can look up those names • When someone looks up a URI, provide useful information, using the standards (RDF*, SPARQL) • Include links to other URIs, so that they can discover more things” Tim Berners-Lee. Linked data-design issues (2006) http://www. w3.org/DesignIssues/LinkedData.html Leo Sauermann and Richard Cyganiak. Cool URIs for the Semantic Web (2008) http://www.w3.org/TR/cooluris/ Tom Heath and Christian Bizer. Linked Data: Evolving the Web into a Global Data Space (2011) http://linkeddatabook.com/
  6. 6. Center for Open Middleware Let´s see an example 6 Nandana Sampath Mihindukulasooriya http://id.nandana.org/card#me GET /card#me HTTP/1.1 Host: id.nandana.org HTTP/1.1 200 ok OK Content-Type: text/turtle; charset=UTF-8 Content-Length: 250 content-type: text/turtle; charset=utf-8 content-length: 250 @prefix dc: <http://purl.org/dc/terms/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . (1) (2) <http://example.org/nandana> a foaf:PersonalProfileDocument; personalprofiledocument; foaf:primarytopic primaryTopic <<http://http://example.example.org/org/nandana#nandana#me> me> ; ; dc:title ‘nandana’s Nandana’s foaf FOAF personal personal profile’ profile’ . . <http://example.org/nandana#me> a foaf:Person; person; foaf:name ‘Nandana nandana mihindukulasooriya’ Mihindukulasooriya’ ; . foaf:workplacehomepage <http://www.oeg-upm.net/> ; foaf:workplacehomepage <http://www.centeropenmiddleware.com/> ; foaf:schoolhomepage <http://www.fi.upm.es/> ; foaf:topic_interest <http://dbpedia.org/resource/linked_data> ; foaf:based_near <http://dbpedia.org/resource/madrid> . (3) (4)
  7. 7. Center for Open Middleware Linked Data in practice 7 • Linked Data resources (documents) • easier to traverse, live data, less computational cost to the provider • slow querying • Public SPARQL endpoints • live data • high cost to the provider, low availability • Data dumps + private SPARQL endpoints • set up and maintenance cost, stale data, silos • high availability and performance • Linked Data Fragments • less workload on server, high availability • more bandwidth, slow querying LDP makes these resources LD+RW
  8. 8. Center for Open Middleware Linked Data Platform 1.0 http://www.w3.org/TR/ldp/ 8 • A standard protocol for Read / Write Linked Data • Extensions to HTTP protocol • Pagination, ordering, partial updates, introspection, creation factories, collections • Standardization focused of interoperability • Developed by W3C Linked Data Platform Working Group • 54 participants from 32 organizations • Industry: IBM, Oracle, EMC, Fujitsu, OpenLink Software, Base22, … • Academia: Universidad Politécnica de Madrid, University of Oxford, DERI, Université de Lyon, INRIA, … • Progress: • W3C LDP Working Group is launched, June 2014, • W3C Last Call Working Draft (3), 7 September 2014, • W3C Proposed Recommendation, October-November 2014
  9. 9. Center for Open Middleware LDP Terminology 9 conforms to the lifecycle patterns and conventions defined in LDP state is fully represented in RDF state is NOT represented in RDF a special type of RDF Source that acts as • an enumeration of a collection of linked documents • a creation factory
  10. 10. Center for Open Middleware Learning W3C Linked Data Platform 1.0 with examples EXAMPLES 10
  11. 11. Center for Open Middleware Few simple scenarios 11 • Looking up a Linked Data resource (GET on LDPR) • Modifying a Linked Data resource (PUT/PATCH on LDPR) • Creating Linked Data resources • Basic Container (POST on LDP-BC) • Direct Container (POST on LDP-DC) • Indirect Container (POST on LDP-IC) • PUT to create • Creating Linked Data Platform containers • Deleting a Linked Data resource (DELETE on LDPR) • Managing non-RDF resources
  12. 12. Center for Open Middleware Looking up a Linked Data resource 12 Nandana´s FOAF file • a simple HTTP GET with • additional guarantees • LDP mandates some features that are optional in HTTP • e.g., e-tags, HEAD, OPTIONS • Some extensions • e.g., paging GET GET 200 OK
  13. 13. Center for Open Middleware Looking up a Linked Data resource GET on LDPR 13 GET /nandana HTTP/1.1 Host: example.org Accept: text/turtle HTTP/1.1 200 OK Content-Type: text/turtle; charset=UTF-8 Link: <http://www.w3.org/ns/ldp#Resource>; rel=“type” ETag: “123456789” Allow: OPTIONS,HEAD,GET,PUT,PATCH Accept-Patch: text/ldpatch Content-Length: 250 @prefix dc: <http://purl.org/dc/terms/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <http://example.org/nandana> a foaf:PersonalProfileDocument; foaf:primaryTopic <http://example.org/nandana#me> ; dc:title ‘Nandana’s FOAF file’ . <http://example.org/nandana#me> a foaf:Person; foaf:name ‘Nandana Mihindukulasooriya’; foaf:currentProject <http://www.seals-project.eu/> . GET 200 OK
  14. 14. Center for Open Middleware Looking up a Linked Data document GET on LDPR 14 GET /nandana HTTP/1.1 Host: example.org Accept: text/turtle HTTP/1.1 conformant has Turtle and JSON-LD representations advertises support for LDP HTTP/1.1 200 OK Content-Type: text/turtle; charset=UTF-8 Link: <http://www.w3.org/ns/ldp#Resource>; rel=“type” ETag: “123456789” Allow: OPTIONS,HEAD,GET,PUT,PATCH Accept-Patch: text/ldpatch Content-Length: 250 @prefix dc: <http://purl.org/dc/terms/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . advertises which operations are allowed provides an entity tag supports the OPTIONS,HEAD, and PATCH operations <http://example.org/nandana> a foaf:PersonalProfileDocument; foaf:primaryTopic <http://example.org/nandana#me> ; dc:title ‘Nandana’s FOAF file’ . <http://example.org/nandana#me> a foaf:Person; foaf:name ‘Nandana Mihindukulasooriya’; foaf:currentProject <http://www.seals-project.eu/> . advertises media types accepted by the PATCH method reuses existing vocabularies use standard vocabularies [ e.g., Dublin Core, RDF(S) ] has at least one rdf:type set explicitly
  15. 15. Center for Open Middleware Looking up a Linked Data document GET on LDPR with paging 15 GET /nandana HTTP/1.1 Host: example.org Accept: text/turtle Prefer: return=representation; max-triple-count="500" HTTP/1.1 303 See Other Location: <http://example.org/nandana?page1> redirects to the first page GET 303 See Other communicates support for LDP Paging and maximum desired size
  16. 16. Center for Open Middleware Looking up a Linked Data document GET on LDPR with paging communicates support for LDP Paging and maximum desired size GET 16 GET /nandana HTTP/1.1 Host: example.org Accept: text/turtle Prefer: return=representation; max-triple-count="500" HTTP/1.1 303 See Other Location: <http://example.org/nandana?page1> GET /nandana?page1 HTTP/1.1 Host: example.org Accept: text/turtle Prefer: return=representation; max-triple-count="500" HTTP/1.1 200 OK Content-Type: text/turtle ETag: "_87e52ce291112" Link: <http://www.w3.org/ns/ldp#Resource>; rel="type", <http://www.w3.org/ns/ldp#Page>; rel="type" Link: <http://example.org/customer-relations?p=2>; rel='next' Link: <http://example.org/nandana>; rel='canonical'; etag="_87e52ce291110" Allow: GET,OPTIONS,HEAD @prefix dc: <http://purl.org/dc/terms/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <http://example.org/nandana> a foaf:PersonalProfileDocument; foaf:primaryTopic <http://example.org/nandana#me> ; dc:title ‘Nandana’s FOAF file’ . <http://example.org/nandana#me> a foaf:Person; foaf:name ‘Nandana Mihindukulasooriya’; … redirects to the first page GET 303 See Other GET advertises the response representation is a pa2g0e0 OK provides a link to the next page provides a link to resource being paged and the entity tag of complete resource
  17. 17. Center for Open Middleware Looking up a Linked Data document GET on LDPR with paging (optimized) 17 GET /nandana HTTP/1.1 Host: example.org Accept: text/turtle Prefer: return=representation; max-triple-count="500“ Prefer: contents-of-related HTTP/1.1 209 Contents of Related Content-Type: text/turtle ETag: "_87e52ce291112" Link: <http://www.w3.org/ns/ldp#Resource>; rel="type", <http://www.w3.org/ns/ldp#Page>; rel="type" Link: <http://example.org/customer-relations?p=2>; rel='next' Link: <http://example.org/nandana>; rel='canonical'; etag="_87e52ce291110" Allow: GET,OPTIONS,HEAD @prefix dc: <http://purl.org/dc/terms/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <http://example.org/nandana> a foaf:PersonalProfileDocument; foaf:primaryTopic <http://example.org/nandana#me> ; dc:title ‘Nandana’s FOAF file’ . <http://example.org/nandana#me> a foaf:Person; foaf:name ‘Nandana Mihindukulasooriya’; … communicates support for LDP Paging and maximum desired size communicates that the client understand “contents-of-related” status code advertises the response representation is a page provides a link to the next page provides a link to resource being paged and the entity tag of complete resource
  18. 18. Center for Open Middleware Few simple scenarios 18 • Looking up a Linked Data resource (GET on LDPR) • Modifying a Linked Data resource (PUT/PATCH on LDPR) • Creating Linked Data resources • Basic Container (POST on LDP-BC) • Direct Container (POST on LDP-DC) • Indirect Container (POST on LDP-IC) • PUT to create • Deleting a Linked Data resource (DELETE on LDPR) • Managing non-RDF resources
  19. 19. Center for Open Middleware Modifying a Linked Data resource 19 • uses HTTP PUT or PATCH operations • encourages conditional requests to avoid “lost update” problem GET 200 OK ETag: “123456789” If-Match: W/'123456789' PUT/PATCH Nandana´s FOAF file GET 204 No Content Modify
  20. 20. Center for Open Middleware Modifying a Linked Data resource PUT on LDPR 20 PUT /nandana HTTP/1.1 Host: example.org If-Match: W/'123456789' Content-Type: text/turtle @prefix dc: <http://purl.org/dc/terms/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . uses conditional requests <http://example.org/nandana> a foaf:PersonalProfileDocument; foaf:primaryTopic <http://example.org/nandana#me> ; dc:title ‘Nandana’s FOAF file’ . <http://example.org/nandana#me> a foaf:Person; foaf:name ‘Nandana Mihindukulasooriya’; foaf:currentProject <http://www.ldp4j.org/> . HTTP/1.1 204 No Content Link: <http://www.w3.org/ns/ldp#Resource>; rel=‘type’ modifies one triple PUT 204 No Content
  21. 21. Center for Open Middleware Modifying a Linked Data resource PATCH on LDPR 21 PATCH /nandana HTTP/1.1 Host: example.org If-Match: W/'123456789' Content-Type: text/ldpatch @prefix foaf: <http://xmlns.com/foaf/0.1/> . Delete <http://example.org/nandana#me> foaf:currentProject <http://www.seals-project.eu/>. Add <http://example.org/nandana#me> foaf:currentProject <http://www.ldp4j.org/>. HTTP/1.1 204 No Content Link: <http://www.w3.org/ns/ldp#Resource>; rel=‘type’ uses conditional requests uses LDP Patch format PATCH 204 No Content
  22. 22. Center for Open Middleware Modifying a Linked Data resource Constraint validation errors 22 publishes any constraints on create/update HTTP/1.1 422 Unprocessable Entity Link: <http://www.w3.org/ns/ldp#Resource>; rel=‘type’ Link: <http://example.org/constraints/101>; rel=‘http://www.w3.org/ns/ldp#constrainedBy’ 422 Unprocessable Entity • constrainedBy link provides any constraints on the update GET /constraints/101 HTTP/1.1 Host: example.org Accept: */* HTTP/1.1 200 OK Content-Type: text/plain; charset=UTF-8 Content-Length: 150 constraints can be machine readable (better) or in natural language When modifying the current project of a person, the information about the past projects should be preserved using the foaf:pastProject property. Suggested Update: @prefix foaf: <http://xmlns.com/foaf/0.1/> . Delete <http://example.org/nandana#me> foaf:currentProject <http://www.seals-project.eu/>. Add <http://example.org/nandana#me> foaf:currentProject <http://www.ldp4j.org/>. Add <http://example.org/nandana#me> foaf:pastProject < http://www.seals-project.eu/>. GET 200 OK
  23. 23. Center for Open Middleware Few simple scenarios 23 • Looking up a Linked Data resource (GET on LDPR) • Modifying a Linked Data resource (PUT/PATCH on LDPR) • Creating Linked Data resources • Basic Container (POST on LDP-BC) • Direct Container (POST on LDP-DC) • Indirect Container (POST on LDP-IC) • PUT to create • Deleting a Linked Data resource (DELETE on LDPR) • Managing non-RDF resources
  24. 24. Center for Open Middleware LDP Basic Container 24 • Allows creation of new resources through POST • Maintains containment triples Subject Predicate Object Pattern LDPC-URI ldp:contains document-URI Example http://example.org/nandana/contacts/ ldp:contains http://example.org/nandana/contacts/raul Nandana’s Contact List <<Basic Container>> Raul’s Contact Miguel’s Contact ldp:contains ldp:contains http://example.org/nandana/contacts/ http://example.org/nandana/contacts/raul http://example.org/nandana/contacts/miguel
  25. 25. Center for Open Middleware LDP Basic Container 25 GET /nandana/contacts/ HTTP/1.1 Host: example.org Accept: text/turtle advertises LDP Basic Container semantics GET 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‘ ETag:W/'123456711' Allow: OPTIONS,HEAD,GET,POST Accept-Post: text/turtle Content-Length: 250 @prefix dc: <http://purl.org/dc/terms/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix ldp: <http://www.w3.org/ns/ldp#>. supports the POST method 200 OK advertises media types accepted by the POST method <http://example.org/nandana/contacts/> a ldp:Container, ldp:BasicContainer; has containment triples dc:title ‘Nandana’s contact list’; ldp:contains <http://example.org/nandana/friends/raul>, <http://example.org/nandana/friends/miguel> .
  26. 26. Center for Open Middleware LDP Basic Container Creating an LDPR 26 Nandana’s Contact List <<Basic Container>> Raul’s Contact Miguel’s Contact ldp:contains ldp:contains Fernando’s Contact POST
  27. 27. Center for Open Middleware LDP Basic Container Creating an LDPR 27 POST /nandana/contacts/ HTTP/1.1 Host: example.org Slug: fernando Link: <http://www.w3.org/ns/ldp#Resource>; rel='type' Content-Type: text/turtle @prefix vcard: <http://www.w3.org/2006/vcard/ns#> . <> a vcard:Individual; vcard:hasURL <http://example.org/fernando#me> ; vcard:hasEmail <mailto:fernado@example.com>; vcard:fn "Fernando Serena"; vcard:hasTelephone [ a vcard:Home, vcard:Voice; vcard:hasValue <tel:+34655555555> ] . HTTP/1.1 201 Created Location: http://example.org/nandana/contacts/fernando Link: <http://www.w3.org/ns/ldp#Resource>; rel=‘type’ Content-Length: 0 POST 201 Created
  28. 28. Center for Open Middleware LDP Basic Container Creating an LDPR 28 POST /nandana/contacts/ HTTP/1.1 Host: example.org Slug: fernando Link: <http://www.w3.org/ns/ldp#Resource>; rel='type' Content-Type: text/turtle @prefix vcard: <http://www.w3.org/2006/vcard/ns#> . <> a vcard:Individual; vcard:hasURL <http://example.org/fernando#me> ; vcard:hasEmail <mailto:fernado@example.com>; vcard:fn "Fernando Serena"; vcard:hasTelephone [ a vcard:Home, vcard:Voice; vcard:hasValue <tel:+34655555555> ] . provides a hint for the new URI to be minted HTTP/1.1 201 Created Location: http://example.org/nandana/contacts/fernando Link: <http://www.w3.org/ns/ldp#Resource>; rel=‘type’ Content-Length: 0 POST requests the LDPR interaction model a null URI is used to refer to the resource to be created 201 Created provides the URI of the newly created resource
  29. 29. Center for Open Middleware LDP Basic Container After the resource creation 29 Nandana’s Contact List <<Basic Container>> Raul’s Contact Miguel’s Contact ldp:contains ldp:contains Fernando’s Contact ldp:contains
  30. 30. Center for Open Middleware LDP Basic Container After the resource creation 30 GET /nandana/contacts/ HTTP/1.1 Host: example.org Accept: text/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‘ ETag: W/'123456712' Allow: OPTIONS,HEAD,GET,POST Accept-Post: text/turtle Content-Length: 250 @prefix dc: <http://purl.org/dc/terms/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix ldp: <http://www.w3.org/ns/ldp#>. a containment triple is added for the newly created resource <http://example.org/nandana/contacts/> a a ldp:Container, ldp:BasicContainer; dc:title ‘Nandana’s contact list’; ldp:contains <http://example.org/nandana/friends/raul>, <http://example.org/nandana/friends/miguel> , <http://example.org/nandana/friends/fernando> . GET 200 OK
  31. 31. Center for Open Middleware Few simple scenarios 31 • Looking up a Linked Data resource (GET on LDPR) • Modifying a Linked Data resource (PUT/PATCH on LDPR) • Creating Linked Data resources • Basic Container (POST on LDP-BC) • Direct Container (POST on LDP-DC) • Indirect Container (POST on LDP-IC) • PUT to create • Deleting a Linked Data resource (DELETE on LDPR) • Managing non-RDF resources
  32. 32. Center for Open Middleware Isn’t LDP Basic Containers enough? 32 • For most use cases, may be. • There are some limitations • can’t use domain-specific relationships • containment triples have a fixed pattern for <s, p, o> of the triple • containment triples can say relationships among two web resources (the LDPC and resources created using it) • some use cases require relationships between resources other than the LDP Container itself • some use cases require relationship among real world resource (in contrast to information resources / documents) • LDP Direct/Indirect containers introduce membership triples to address aforementioned limitations
  33. 33. Center for Open Middleware LDP Direct Container 33 • Maintains the containment triple similar to the basic containers • Maintains membership triples defined in the container Subject Predicate Object Pattern membership-constant-URI membership-predicate member-derived-URI Example http://example.org/nandana#me foaf:knows http://example.org/nandana/contacts/raul • Domain vocabularies can be used in membership predicate http://example.org/nandana/contacts/ Nandana’s Contact List <<Direct Container>> http://example.org/nandana/contacts/raul Raul’s Contact http://example.org/nandana/contacts/miguel Miguel’s Contact ldp:contains ldp:contains Nandana foaf:knows http://example.org/nandana#me foaf:knows
  34. 34. Center for Open Middleware Direct Containers 34 HTTP/1.1 200 OK Content-Type: text/turtle; charset=UTF-8 Link: <http://www.w3.org/ns/ldp#DirectContainer>; rel='type', <http://www.w3.org/ns/ldp#Resource>; rel='type‘ ETag: W/'123456711' Allow: OPTIONS,HEAD,GET,POST Accept-Post: text/turtle Content-Length: 250 @prefix dc: <http://purl.org/dc/terms/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix ldp: <http://www.w3.org/ns/ldp#>. advertises LDP Basic Container interaction model defines the membership-constant-URI <http://example.org/nandana/friends/> a a ldp:Container, ldp:DirectContainer; ldp:membershipResource <http://example.org/nandana#me>; ldp:hasMemberRelation foaf:knows; dc:title ‘Nandana’s contact list’; ldp:contains <http://example.org/nandana/friends/raul>, <http://example.org/nandana/friends/miguel> . defines the membership predicate contains membership triples <http://example.org/nandana#me> foaf:knows <http://example.org/nandana/friends/raul>, <http://example.org/nandana/friends/miguel> . 200 OK
  35. 35. Center for Open Middleware LDP Basic Container Creating an LDPR 35 Fernando’s Contact http://example.org/nandana/contacts/ POST Nandana’s Contact List <<Direct Container>> http://example.org/nandana/contacts/raul Raul’s Contact Miguel’s Contact ldp:contains ldp:contains Nandana foaf:knows foaf:knows http://example.org/nandana#me http://example.org/nandana/contacts/miguel
  36. 36. Center for Open Middleware LDP Direct Container Creating an LDPR 36 POST /nandana/contacts/ HTTP/1.1 Host: example.org Slug: fernando Link: <http://www.w3.org/ns/ldp#Resource>; rel='type' Content-Type: text/turtle @prefix vcard: <http://www.w3.org/2006/vcard/ns#> . <> a vcard:Individual; vcard:hasURL <http://example.org/fernando#me> ; vcard:hasEmail <mailto:fernado@example.com>; vcard:fn "Fernando Serena"; vcard:hasTelephone [ a vcard:Home, vcard:Voice; vcard:hasValue <tel:+34655555555> ] . HTTP/1.1 201 Created Location: http://example.org/nandana/contacts/fernando Link: <http://www.w3.org/ns/ldp#Resource>; rel=‘type’ Content-Length: 0 POST 201 Created
  37. 37. Center for Open Middleware Direct Containers After the resource creation 37 http://example.org/nandana/contacts/ Nandana’s Contact List <<Direct Container>> http://example.org/nandana/contacts/raul Raul’s Contact Miguel’s Contact ldp:contains ldp:contains Nandana foaf:knows foaf:knows http://example.org/nandana#me http://example.org/nandana/contacts/miguel Fernando’s Contact foaf:knows ldp:contains http://example.org/nandana/contacts/fernando
  38. 38. Center for Open Middleware Direct Containers After the resource creation 38 HTTP/1.1 200 OK Content-Type: text/turtle; charset=UTF-8 Link: <http://www.w3.org/ns/ldp#DirectContainer>; rel='type', <http://www.w3.org/ns/ldp#Resource>; rel='type‘ ETag: W/'123456711' Allow: OPTIONS,HEAD,GET,POST Accept-Post: text/turtle Content-Length: 250 @prefix dc: <http://purl.org/dc/terms/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix ldp: <http://www.w3.org/ns/ldp#>. a containment triple is added for the newly created resource <http://example.org/nandana/friends/> a a ldp:Container, ldp:DirectContainer; ldp:membershipResource <http://example.org/nandana#me>; ldp:hasMemberRelation foaf:knows; dc:title ‘Nandana’s contact list’; ldp:contains <http://example.org/nandana/friends/raul>, <http://example.org/nandana/friends/miguel>, <http://example.org/nandana/friends/fernando> . <http://example.org/nandana#me> foaf:knows <http://example.org/nandana/friends/raul>, <http://example.org/nandana/friends/miguel> , <http://example.org/nandana/friends/fernando> . a membership triple is added for the newly created resource 200 OK
  39. 39. Center for Open Middleware Few simple scenarios 39 • Looking up a Linked Data resource (GET on LDPR) • Modifying a Linked Data resource (PUT/PATCH on LDPR) • Creating Linked Data resources • Basic Container (POST on LDP-BC) • Direct Container (POST on LDP-DC) • Indirect Container (POST on LDP-IC) • PUT to create • Deleting a Linked Data resource (DELETE on LDPR) • Managing non-RDF resources
  40. 40. Center for Open Middleware LDP Indirect Container 40 Subject Predicate Object Pattern membership-constant-URI membership-predicate member-derived-URI Example http://example.org/nandana#me foaf:knows http://example.org/nandana/contacts/raul Nandana’s Contact List <<Indirect Container>> Raul’s Contact ldp:contains http://www.garcia-castro.com/foaf#me foaf:knows http://example.org/nandana#me http://example.org/miguel#me Nandana foaf:knows Raul Miguel • Maintains the containment triple similar to the basic containers • Maintains membership triples • Full flexibility with the membership triples defined in the container Miguel’s Contact ldp:contains
  41. 41. Center for Open Middleware Indirect Containers 41 HTTP/1.1 200 OK Content-Type: text/turtle; charset=UTF-8 Link: <http://www.w3.org/ns/ldp#DirectContainer>; rel='type', <http://www.w3.org/ns/ldp#Resource>; rel='type‘ ETag:W/'123456711' Allow: OPTIONS,HEAD,GET,POST Accept-Post: text/turtle Content-Length: 250 @prefix dc: <http://purl.org/dc/terms/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix ldp: <http://www.w3.org/ns/ldp#>. @prefix vcard: <http://www.w3.org/2006/vcard/ns#> . ldp:insertedContentRelation defines how to select the object of the membership triple <http://example.org/nandana/friends/> a a ldp:Container, ldp:IndirectContainer; 200 OK ldp:membershipResource <http://example.org/nandana#me>; ldp:hasMemberRelation foaf:knows; ldp:insertedContentRelation vcard:hasURL; dc:title ‘Nandana’s contact list’; ldp:contains <http://example.org/nandana/friends/raul>, <http://example.org/nandana/friends/miguel> . <http://example.org/nandana#me> foaf:knows <http://www.garcia-castro.com/foaf#me>, <http://example.org/miguel#me> .
  42. 42. Center for Open Middleware LDP Indirect Container Creating an LDPR 42 Nandana’s Contact List <<Indirect Container>> ldp:contains ldp:contains Nandana foaf:knows foaf:knows Raul’s Contact Miguel’s Contact http://www.garcia-castro.com/foaf#me http://example.org/nandana#me Raul POST Fernando <> v:hasURL <#me>. Raul http://example.org/miguel#me
  43. 43. Center for Open Middleware LDP Indirect Container Creating an LDPR 43 POST /nandana/contacts/ HTTP/1.1 Host: example.org Slug: fernando Content-Type: text/turtle @prefix vcard: <http://www.w3.org/2006/vcard/ns#> . <> a vcard:Individual; vcard:hasURL <#me> ; vcard:hasEmail <mailto:fernado@example.com>; vcard:fn "Fernando Serena"; vcard:hasTelephone [ a vcard:Home, vcard:Voice; vcard:hasValue <tel:+34655555555> ] . POSTed resource contains a triple with the predicate defined in the ldp:insertedContentRelation HTTP/1.1 201 Created Location: http://example.org/nandana/friends/fernando Link: <http://www.w3.org/ns/ldp#Resource>; rel=‘type’ Content-Length: 0 POST 201 Created
  44. 44. Center for Open Middleware Indirect Containers After the resource creation 44 Nandana’s Contact List <<Indirect Container>> ldp:contains ldp:contains Nandana foaf:knows foaf:knows foaf:knows http://www.garcia-castro.com/foaf#me http://example.org/nandana#me Raul http://example.org/miguel#me http://example.org/fernando#me ldp:contains Raul Miguel Fernando Miguel Fernando
  45. 45. Center for Open Middleware Indirect Containers After the resource creation 45 HTTP/1.1 200 OK Content-Type: text/turtle; charset=UTF-8 Link: <http://www.w3.org/ns/ldp#IndirectContainer>; rel='type', <http://www.w3.org/ns/ldp#Resource>; rel='type‘ ETag: W/'123456711' Allow: OPTIONS,HEAD,GET,POST Accept-Post: text/turtle Content-Length: 250 @prefix dc: <http://purl.org/dc/terms/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix ldp: <http://www.w3.org/ns/ldp#>. <http://example.org/nandana/friends/> a a ldp:Container, ldp:DirectContainer; ldp:membershipResource <http://example.org/nandana#me>; ldp:hasMemberRelation foaf:knows; dc:title ‘Nandana’s friends’; ldp:contains <http://example.org/nandana/friends/raul>, <http://example.org/nandana/friends/miguel>, <http://example.org/nandana/friends/fernando> . <http://example.org/nandana#me> foaf:knows <http://www.garcia-castro.com/foaf#me>, <http://example.org/miguel#me> <http://example.org/fernando#me> . . 200 OK a containment triple is added for the newly created resource a membership triple is added for the newly created resource the object of the membership triple is selected based on ldp:insertedContentRelation
  46. 46. Center for Open Middleware Few simple scenarios 46 • Looking up a Linked Data resource (GET on LDPR) • Modifying a Linked Data resource (PUT/PATCH on LDPR) • Creating Linked Data resources • Basic Container (POST on LDP-BC) • Direct Container (POST on LDP-DC) • Indirect Container (POST on LDP-IC) • PUT to create (PUT) • Deleting a Linked Data resource (DELETE on LDPR) • Managing non-RDF resources
  47. 47. Center for Open Middleware Creating a Linked Data resource PUT on a non-existing URI 47 • Clients can decide the URI to be used PUT /nandana/contacts/fernando HTTP/1.1 Host: example.org Content-Type: text/turtle the URI for the resource to be created @prefix vcard: <http://www.w3.org/2006/vcard/ns#> . < http://example.org/nandana/contacts/fernando> a vcard:Individual; vcard:hasURL <http://example.org/fernando#me> ; vcard:hasEmail <mailto:fernado@example.com>; vcard:fn "Fernando Serena"; vcard:hasTelephone [ a vcard:Home, vcard:Voice; vcard:hasValue <tel:+34655555555> ] . HTTP/1.1 204 No Content Link: <http://www.w3.org/ns/ldp#Resource>; rel=‘type’ PUT 204 No Content
  48. 48. Center for Open Middleware Few simple scenarios 48 • Looking up a Linked Data resource (GET on LDPR) • Modifying a Linked Data resource (PUT/PATCH on LDPR) • Creating Linked Data resources • Basic Container (POST on LDP-BC) • Direct Container (POST on LDP-DC) • Indirect Container (POST on LDP-IC) • PUT to create • Deleting a Linked Data resource (DELETE on LDPR) • Managing non-RDF resources
  49. 49. Center for Open Middleware Deleting a Linked Data document 49 DELETE /nandana/contacts/fernando HTTP/1.1 Host: example.org HTTP/1.1 204 No Content Link: <http://www.w3.org/ns/ldp#Resource>; rel=‘type’ DELETE 204 No Content • Corresponding containment triples and membership triples will be removed from the containers upon deletion • E.g., in the Indirect Container example following triples will be removed @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix ldp: <http://www.w3.org/ns/ldp#>. <http://example.org/nandana/contacts/> ldp:contains <http://example.org/nandana/contacts/fernando> . <http://example.org/nandana#me> foaf:knows <http://example.org/fernando#me> .
  50. 50. Center for Open Middleware Few simple scenarios 50 • Looking up a Linked Data resource (GET on LDPR) • Modifying a Linked Data resource (PUT/PATCH on LDPR) • Creating Linked Data resources • Basic Container (POST on LDP-BC) • Direct Container (POST on LDP-DC) • Indirect Container (POST on LDP-IC) • PUT to create • Deleting a Linked Data resource (DELETE on LDPR) • Managing non-RDF resources
  51. 51. Center for Open Middleware Managing non-RDF resources A container for managing photos 51 • LDPRs can be non-RDF sources (LDP-NR) • An LDP-NR source typically has an associated LDP-RS to contain data about the LDP-NR Nandana’s Photo Gallery <<Basic Container>> ldp:contains ldp:contains describedby describedby http://example.org/nandana/photos/ http://example.org/nandana/photos/sigiriya http://example.org/nandana/photos/sigiriya/meta http://example.org/nandana/photos/eiffel http://example.org/nandana/photos/eiffel/meta
  52. 52. Center for Open Middleware 52 Managing non-RDF resources A container for managing photos OPTIONS /nandana/photos/ HTTP/1.1 Host: example.org OPTIONS HTTP/1.1 204 No Content Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel='type', <http://www.w3.org/ns/ldp#Resource>; rel='type' Allow: OPTIONS,HEAD,GET,POST Accept-Post: image/png, image/jpeg 204 No Content advertises support for non-RDF (binary) resource creation
  53. 53. Center for Open Middleware 53 Managing non-RDF resources Creating a new binary resource http://example.org/nandana/photos/Nandana’s Photo Gallery <<Basic Container>> ldp:contains ldp:contains http://example.org/nandana/photos/ http://example.org/nandana/photos/sigiriya POST
  54. 54. Center for Open Middleware 54 Managing non-RDF resources Creating a new binary resource POST /nandana/photos/ HTTP/1.1 Host: example.org Slug: monalisa Content-Type: image/png Content- Length: 1020 ### binary content of the image ### POST HTTP/1.1 201 Created 201 Created Location: http://example.org/nandana/photos/monalisa Link: <http://www.w3.org/ns/ldp#NonRDFSource>; rel="type“, <http://www.w3.org/ns/ldp#Resource>; rel="type“ Link: <http://example.org/nandana/photos/monalisa/meta>; rel="describedby“ Content-Length: 0 provides the URI of the newly created resource provides the URI of an associated LDP-RS that contains the data about the binary resource
  55. 55. Center for Open Middleware 55 Managing non-RDF resources Looking up the new binary resource GET /nandana/photos/monalisa HTTP/1.1 Host: example.org Accept: image/png HTTP/1.1 200 OK Content-Type: image/png Link: <http://www.w3.org/ns/ldp#NonRDFSource>; rel="type“, <http://www.w3.org/ns/ldp#Resource>; rel="type“ Link: <http://example.org/nandana/photos/monalisa/meta>; rel="describedby“ ETag: “123456790” Allow: OPTIONS,HEAD,GET, DELETE Content-Length: 1020 ### binary content of the image ### GET 200 OK provides the URI of an associated LDP-RS that contains the data about the binary resource
  56. 56. Center for Open Middleware 56 Managing non-RDF resources Looking up the associated LDP-RS GET /nandana/photos/monalisa/meta HTTP/1.1 Host: example.org Accept: text/turtle HTTP/1.1 200 OK Content-Type: text/turtle Link: <http://www.w3.org/ns/ldp#Resource>; rel="type“ ETag: “123456793” Allow: OPTIONS,HEAD,GET, PUT, DELETE prefix wdrs: <http://www.w3.org/2007/05/powder-s#> . @prefix dcterms: <http://purl.org/dc/terms/> . <http://example.org/nandana/photos/monalisa> wdrs:describedby <http://example.org/nandana/photos/monalisa/meta> ; dcterms:creator <http://example.org/nandana#me>; dcterms:created "2013-05-05T10:00"^^xsd:dateTime . GET 200 OK
  57. 57. Center for Open Middleware References 57 • Linked Data Platform 1.0 • http://www.w3.org/TR/ldp/ • Linked Data Platform 1.0 Primer • http://www.w3.org/TR/ldp-primer/ • Linked Data Platform Best Practices and Guidelines • http://www.w3.org/TR/ldp-bp/ • Linked Data Platform Paging 1.0 • http://www.w3.org/TR/ldp-paging/ • Linked Data Patch Format • http://www.w3.org/TR/ldpatch/
  58. 58. Center for Open Middleware Nandana Mihindukulasooriya, Center for Open Middleware / Ontology Engineering Group Universidad Politécnica de Madrid, Spain. Questions? @nandanamihindu nmihindu@fi.upm.es

×