Using Virtuoso as LDP Client and Server

What is the Linked Data Platform (LDP)?

Use of HTTP to Create, Read, Update, and Delete Linked Data Resources (Documents) that are part of a collection (folder). Naturally, this kind of task posses the following questions and associated challenges:

The Linked Data Platform (LDP) was developed by W3C members to answer many of these questions.

Why is the LDP important?

It formalizes Linked Data deployment and use by standardizing the representation and behavior of, and the generation and processing of HTTP requests regarding, Linked Data Platform Resources (LDPRs) and Linked Data Platform Containers (LDPCs). Using the Linked Data Platform thereby increases availability and accessibility of Linked Data on the Web.

How to use Virtuoso's LDP features

Virtuoso's LDP functionality is a built-in, integral part of the product.

Virtuoso operates as an LDP Client, generating HTTP requests and processing HTTP responses that conform to the rules defined for LDPRs and LDPCs, when it is operating against LDP Servers.

Virtuoso also operates as an LDP Server, by processing HTTP requests and generating HTTP responses that conform to the rules defined for LDPRs and LDPCs. The following examples use the commandline utility curl to demonstrate Virtuoso's LDP Server implementation.

Example 1: How to enable LDP on a folder/collection

One could use the following options to enable LDP on a given folder/collection of resources:

  1. Via Conductor as a property 'LDP' on the given folder designated as root for LDP:
    1. Log in at http://host:port/conductor and go to "Web Application Server" -> "Content Management":



    2. Provide location path for the destination folder/collection to be LDP enabled, in our example we will enable user's "demo" "Public" folder:



    3. Click in "Action" column the "Updated properties" button:



    4. In the presented form click "Add" button in the "WebDAV" section and enter respectively:
      • for "Property": LDP ;
      • for "Value": ldp:BasicContainer? ;



    5. Finally click "Update".
  2. Via ODS-Briefcase UI:
    1. Go to http://host:port/ods and after providing your user credentials, go to Briefcase:



    2. For the folder/collection to be LDP enabled, click in its "Action" column the "Updated properties" button:



    3. In the presented form click "Add" button in the "WebDAV" section and enter respectively:
      • for "Property": LDP ;
      • for "Value": ldp:BasicContainer? ;



    4. Finally click "Update".
  3. Via command line e.g.:

    DB.DBA.DAV_PROP_SET ('/DAV/ldp/', 'LDP', 'ldp:BasicContainer', 'dav','dav', 1);

Example 2: Create and verify a simple LDPR

  1. Write a bit of text ("This content is not Turtle." in this example) to a text file ("test2.txt") in DAV.

    % curl --verbose -iX PUT -H "Content-Type: text/plain" -u dav:dav -d 'This content is not Turtle.' "http://example.com/DAV/test2.txt" > ldp/ldp1.log

  2. The server's response should resemble this --

    HTTP/1.1 201 Created Server: Virtuoso/06.04.3137 (Linux) x86_64-unknown-linux-gnu VDB Connection: close Date: Fri, 26 Jul 2013 11:59:52 GMT Accept-Ranges: bytes Content-Type: text/plain Link: <>;rel=<http://www.w3.org/ns/ldp/Resource> Content-Length: 172 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML> <HEAD> <TITLE>201 Created</TITLE> </HEAD> <BODY> <H1>Created</H1>Resource /DAV/test2.txt has been created. </BODY> </HTML>

  3. Confirm that the server took the submission as LDP data --

    % curl --verbose -iH "Accept: text/turtle, */*;q=0.1" -u dav:dav http://example.com/DAV/test2.txt > ldp/ldp2.log

  4. The server should return a "text/turtle" LDP response similar to this --

    HTTP/1.1 200 OK Server: Virtuoso/06.04.3136 (Win64) x86_64-generic-win-64 VDB Connection: Keep-Alive Date: Sun, 16 Jun 2013 21:04:04 GMT Accept-Ranges: bytes Content-Type: text/turtle; charset=UTF-8 Content-Length: 472 @prefix dcterms: <http://purl.org/dc/terms/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix ldp: <http://www.w3.org/ns/ldp#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . <http://example.com/DAV/test2.txt> a dcterms:PhysicalResource ; dcterms:title "test2.txt" ; dcterms:creator "dav" ; dcterms:created "2013-06-17 03:04:04" ; dcterms:modified "2013-06-17 03:04:04" ; rdfs:label "test2.txt" .

Example 3: Access Resources in an LDPC (e.g., a DAV folder)

  1. Request all LDP data for an LDPC, such as the DAV root folder, to be returned as Turtle --

    % curl --verbose -iH "Accept: text/turtle, */*;q=0.1" -u dav:dav http://example.com/DAV/ > ldp/ldp3.log

  2. The server should return text/turtle of LDP data describing all Resources (both LDPRs and non LDPRs) inside the container, similar to this --

    HTTP/1.1 200 OK Server: Virtuoso/06.04.3136 (Win64) x86_64-generic-win-64 VDB Connection: Keep-Alive Date: Sun, 16 Jun 2013 21:04:04 GMT Accept-Ranges: bytes Content-Type: text/turtle; chartset=UTF-8 Content-Length: 621 @prefix dcterms: <http://purl.org/dc/terms/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix ldp: <http://www.w3.org/ns/ldp#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . <http://example.com/DAV/> a ldp:Container ; dcterms:title "DAV" ; dcterms:creator "dav" ; dcterms:created "2013-06-17 01:18:23" ; dcterms:modified "2013-06-17 01:18:23" ; ldp:membershipPredicate rdfs:member ; rdfs:member <http://example.com/DAV/VAD/> ; rdfs:member <http://example.com/DAV/home/> ; rdfs:member <http://example.com/DAV/test2.txt> ; rdfs:label "DAV" .

Example 4: Access non-LDP Resources in an LDPC (e.g., DAV folder)

  1. Request that all non-member-properties LDP data for an LDPC, such as the DAV root folder, be returned as Turtle --

    % curl --verbose -iH "Accept: text/turtle, */*;q=0.1" -u dav:dav http://example.com/DAV/?non-member-properties > ldp/ldp4.log

  2. The server should return text/turtle containing LDP data that describes any non-LDP Resources (that is, any Resources which are not LDPRs) inside the container:

    HTTP/1.1 200 OK Server: Virtuoso/06.04.3136 (Win64) x86_64-generic-win-64 VDB Connection: Keep-Alive Date: Sun, 16 Jun 2013 21:04:04 GMT Accept-Ranges: bytes Content-Type: text/turtle; chartset=UTF-8 Content-Length: 477 @prefix dcterms: <http://purl.org/dc/terms/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix ldp: <http://www.w3.org/ns/ldp#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . <http://example.com/DAV/> a ldp:Container ; dcterms:title "DAV" ; dcterms:creator "dav" ; dcterms:created "2013-06-17 01:18:23" ; dcterms:modified "2013-06-17 01:18:23" ; ldp:membershipPredicate rdfs:member ; rdfs:label "DAV" .

Example 5: Create an LDPR from an existing text file containing Turtle data

  1. Suppose you have a file named ldp-books.ttl, in a folder named temp, with the following Turtle content --

    @prefix : <http://example.org/book/> . @prefix ns: <http://example.org/ns#> . :book1 <http://purl.org/dc/elements/1.1/title> "LDP Tutorial" ; ns:price 42 ; ns:discount 0.2 . :book2 <http://purl.org/dc/elements/1.1/title> "The Semantic Web" ; ns:price 23 ; ns:discount 0.25 .

  2. Upload the file to DAV --

    % curl --verbose -iX PUT -d @temp/ldp-books.ttl -u dav:dav -H 'Content-Type: text/turtle' http://example.com/DAV/test4.ttl > ldp/ldp5.log

  3. The server's response should resemble the following --

    HTTP/1.1 201 Created Server: Virtuoso/06.04.3136 (Win64) x86_64-generic-win-64 VDB Connection: close Date: Sun, 16 Jun 2013 21:04:05 GMT Accept-Ranges: bytes Content-Type: text/turtle Link: <>;rel=<http://www.w3.org/ns/ldp/Resource> Content-Length: 172 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML> <HEAD> <TITLE>201 Created</TITLE> </HEAD> <BODY> <H1>Created</H1>Resource /DAV/test4.ttl has been created. </BODY> </HTML>

Related