<docbook><section><title>VirtLDP</title><title> Using Virtuoso as LDP Client and Server</title> Using Virtuoso as LDP Client and Server
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> What is the Linked Data Platform (LDP)?</bridgehead>
<para>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:</para>
<itemizedlist mark="bullet" spacing="compact"><listitem>Document Resource Issues <itemizedlist mark="bullet" spacing="compact"><listitem>What resource content notations and across-the-wire content serialization formats should be used? </listitem>
<listitem>How is collision detection for updates handled with maximum concurrent (i.e.
 optimistically)? </listitem>
<listitem>How do client handle changes to associated resources, such as content type changes? </listitem>
<listitem>How servers ease the burden of constraints associated with resource creation? </listitem>
</itemizedlist></listitem>
<listitem>Container/Folder Resource Issues <itemizedlist mark="bullet" spacing="compact"><listitem>To which address/location (URL) on an HTTP network can I POST my resource member or container creation requests? </listitem>
<listitem>How do I GET (retrieve) a list of existing member resources associated with a container? </listitem>
<listitem>How is container ordering of member resources expressed and represented? </listitem>
<listitem>How do I obtain metadata about the resources that are members of a container, and the container resource itself? </listitem>
<listitem>How do I GET retrieve resources that are members of a large container, using paging? </listitem>
<listitem>How do I deal with metadata querying scoped to member resources and container resources?</listitem>
</itemizedlist></listitem>
</itemizedlist><para>The <ulink url="http://www.w3.org/TR/ldp/">Linked Data Platform (LDP)</ulink> was developed by W3C members to answer many of these questions.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> Why is the LDP important?</bridgehead>
<para>It formalizes Linked Data deployment and use by standardizing the representation and behavior of, and the generation and processing of HTTP requests regarding, <ulink url="http://www.w3.org/TR/ldp/#linked-data-platform-resources">Linked Data Platform Resources</ulink> (LDPRs) and <ulink url="http://www.w3.org/TR/ldp/#linked-data-platform-containers">Linked Data Platform Containers</ulink> (LDPCs).
 Using the Linked Data Platform thereby increases availability and accessibility of Linked Data on the Web.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> How to use Virtuoso&#39;s LDP features</bridgehead>
<para>Virtuoso&#39;s LDP functionality is a built-in, integral part of the product.</para>
<para>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.</para>
<para>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&#39;s LDP Server implementation.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> Example 1: How to enable LDP on a folder/collection</bridgehead>
<para>One could use the following options to enable LDP on a given folder/collection of resources:</para>
<orderedlist spacing="compact"><listitem>Via Conductor as a property &#39;LDP&#39; on the given folder designated as root for LDP: <orderedlist spacing="compact"><listitem>Log in at <ulink url="http://host:port/conductor">http://host:port/conductor</ulink>  and go to &quot;Web Application Server&quot; -&gt; &quot;Content Management&quot;: <ulink url="VirtLDP/ldp1.png"><figure><graphic fileref="VirtLDP/ldp1.png" /></figure></ulink> </listitem>
<listitem>Provide location path for the destination folder/collection to be LDP enabled, in our example we will enable user&#39;s &quot;demo&quot; &quot;Public&quot; folder: <ulink url="VirtLDP/ldp2.png"><figure><graphic fileref="VirtLDP/ldp2.png" /></figure></ulink> </listitem>
<listitem>Click in &quot;Action&quot; column the &quot;Updated properties&quot; button: <ulink url="VirtLDP/ldp3.png"><figure><graphic fileref="VirtLDP/ldp3.png" /></figure></ulink> </listitem>
<listitem>In the presented form click &quot;Add&quot; button in the &quot;<ulink url="WebDAV">WebDAV</ulink>&quot; section and enter respectively: <itemizedlist mark="bullet" spacing="compact"><listitem>for &quot;Property&quot;: LDP ; </listitem>
<listitem>for &quot;Value&quot;: ldp:<ulink url="BasicContainer">BasicContainer</ulink> ; <ulink url="VirtLDP/ldp4.png"><figure><graphic fileref="VirtLDP/ldp4.png" /></figure></ulink> </listitem>
</itemizedlist></listitem>
<listitem>Finally click &quot;Update&quot;.
</listitem>
</orderedlist></listitem>
<listitem>Via <ulink url="http://ods.openlinksw.com/dataspace/dav/wiki/ODS/OdsBriefcase">ODS-Briefcase</ulink> UI: <orderedlist spacing="compact"><listitem>Go to <ulink url="http://host:port/ods">http://host:port/ods</ulink>  and after providing your user credentials, go to Briefcase: <ulink url="VirtLDP/ldp5.png"><figure><graphic fileref="VirtLDP/ldp5.png" /></figure></ulink> </listitem>
<listitem>For the folder/collection to be LDP enabled, click in its &quot;Action&quot; column the &quot;Updated properties&quot; button: <ulink url="VirtLDP/ldp6.png"><figure><graphic fileref="VirtLDP/ldp6.png" /></figure></ulink> </listitem>
<listitem>In the presented form click &quot;Add&quot; button in the &quot;<ulink url="WebDAV">WebDAV</ulink>&quot; section and enter respectively: <itemizedlist mark="bullet" spacing="compact"><listitem>for &quot;Property&quot;: LDP ; </listitem>
<listitem>for &quot;Value&quot;: ldp:<ulink url="BasicContainer">BasicContainer</ulink> ; <ulink url="VirtLDP/ldp7.png"><figure><graphic fileref="VirtLDP/ldp7.png" /></figure></ulink> </listitem>
</itemizedlist></listitem>
<listitem>Finally click &quot;Update&quot;.
</listitem>
</orderedlist></listitem>
<listitem>Via command line e.g.: <programlisting>DB.DBA.DAV_PROP_SET (&#39;/DAV/ldp/&#39;, &#39;LDP&#39;, &#39;ldp:BasicContainer&#39;, &#39;dav&#39;,&#39;dav&#39;, 1);
</programlisting></listitem>
</orderedlist><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> Example 2: Create and verify a simple LDPR</bridgehead>
<orderedlist spacing="compact"><listitem>Write a bit of text (&quot;This content is not Turtle.&quot; in this example) to a text file (&quot;test2.txt&quot;) in DAV.
<programlisting>% curl --verbose -iX PUT -H &quot;Content-Type: text/plain&quot; -u dav:dav -d &#39;This content is not Turtle.&#39; &quot;http://example.com/DAV/test2.txt&quot;  &gt; ldp/ldp1.log
</programlisting></listitem>
<listitem>The server&#39;s response should resemble this -- <programlisting>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: &lt;&gt;;rel=&lt;http://www.w3.org/ns/ldp/Resource&gt;
Content-Length: 172

&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML 2.0//EN&quot;&gt;
  &lt;HTML&gt;
    &lt;HEAD&gt;
      &lt;TITLE&gt;201 Created&lt;/TITLE&gt;
    &lt;/HEAD&gt;
    &lt;BODY&gt;
      &lt;H1&gt;Created&lt;/H1&gt;Resource /DAV/test2.txt has been created.
    &lt;/BODY&gt;
  &lt;/HTML&gt;
</programlisting></listitem>
<listitem>Confirm that the server took the submission as LDP data -- <programlisting>% curl --verbose -iH &quot;Accept: text/turtle, */*;q=0.1&quot; -u dav:dav http://example.com/DAV/test2.txt &gt; ldp/ldp2.log
</programlisting></listitem>
<listitem>The server should return a &quot;text/turtle&quot; LDP response similar to this -- <programlisting>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: &lt;http://purl.org/dc/terms/&gt; .
@prefix rdf:     &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .
@prefix rdfs:    &lt;http://www.w3.org/2000/01/rdf-schema#&gt; .
@prefix ldp:     &lt;http://www.w3.org/ns/ldp#&gt; .
@prefix xsd:     &lt;http://www.w3.org/2001/XMLSchema#&gt; .

&lt;http://example.com/DAV/test2.txt&gt;
  a                dcterms:PhysicalResource ;
  dcterms:title    &quot;test2.txt&quot; ;
  dcterms:creator  &quot;dav&quot; ;
  dcterms:created  &quot;2013-06-17 03:04:04&quot; ;
  dcterms:modified &quot;2013-06-17 03:04:04&quot; ;
  rdfs:label       &quot;test2.txt&quot; .
</programlisting></listitem>
</orderedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Example 3: Access Resources in an LDPC (e.g., a DAV folder)</bridgehead>
<orderedlist spacing="compact"><listitem>Request all LDP data for an LDPC, such as the DAV root folder, to be returned as Turtle -- <programlisting>% curl --verbose -iH &quot;Accept: text/turtle, */*;q=0.1&quot; -u dav:dav http://example.com/DAV/ &gt; ldp/ldp3.log
</programlisting></listitem>
<listitem>The server should return text/turtle of LDP data describing all Resources (both LDPRs and non LDPRs) inside the container, similar to this -- <programlisting>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: &lt;http://purl.org/dc/terms/&gt; .
@prefix rdf:     &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .
@prefix rdfs:    &lt;http://www.w3.org/2000/01/rdf-schema#&gt; .
@prefix ldp:     &lt;http://www.w3.org/ns/ldp#&gt; .
@prefix xsd:     &lt;http://www.w3.org/2001/XMLSchema#&gt; .

&lt;http://example.com/DAV/&gt;
  a                       ldp:Container ;
  dcterms:title           &quot;DAV&quot; ;
  dcterms:creator         &quot;dav&quot; ;
  dcterms:created         &quot;2013-06-17 01:18:23&quot; ;
  dcterms:modified        &quot;2013-06-17 01:18:23&quot; ;
  ldp:membershipPredicate rdfs:member ;
  rdfs:member             &lt;http://example.com/DAV/VAD/&gt; ;
  rdfs:member             &lt;http://example.com/DAV/home/&gt; ;
  rdfs:member             &lt;http://example.com/DAV/test2.txt&gt; ;
  rdfs:label              &quot;DAV&quot; .
</programlisting></listitem>
</orderedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Example 4: Access non-LDP Resources in an LDPC (e.g., DAV folder)</bridgehead>
<orderedlist spacing="compact"><listitem>Request that all non-member-properties LDP data for an LDPC, such as the DAV root folder, be returned as Turtle -- <programlisting>% curl --verbose -iH &quot;Accept: text/turtle, */*;q=0.1&quot; -u dav:dav http://example.com/DAV/?non-member-properties &gt; ldp/ldp4.log
</programlisting></listitem>
<listitem>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: <programlisting>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: &lt;http://purl.org/dc/terms/&gt; .
@prefix rdf:     &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .
@prefix rdfs:    &lt;http://www.w3.org/2000/01/rdf-schema#&gt; .
@prefix ldp:     &lt;http://www.w3.org/ns/ldp#&gt; .
@prefix xsd:     &lt;http://www.w3.org/2001/XMLSchema#&gt; .

&lt;http://example.com/DAV/&gt;
  a                       ldp:Container ;
  dcterms:title           &quot;DAV&quot; ;
  dcterms:creator         &quot;dav&quot; ;
  dcterms:created         &quot;2013-06-17 01:18:23&quot; ;
  dcterms:modified        &quot;2013-06-17 01:18:23&quot; ;
  ldp:membershipPredicate rdfs:member ;
  rdfs:label              &quot;DAV&quot; .
</programlisting> </listitem>
</orderedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Example 5: Create an LDPR from an existing text file containing Turtle data</bridgehead>
<orderedlist spacing="compact"><listitem>Suppose you have a file named ldp-books.ttl, in a folder named temp, with the following Turtle content -- <programlisting>@prefix    :  &lt;http://example.org/book/&gt; .
@prefix  ns:  &lt;http://example.org/ns#&gt;   .

:book1  &lt;http://purl.org/dc/elements/1.1/title&gt;  &quot;LDP Tutorial&quot;
   ;                                   ns:price  42
   ;                                ns:discount  0.2
   .

:book2  &lt;http://purl.org/dc/elements/1.1/title&gt;  &quot;The Semantic Web&quot;
   ;                                   ns:price  23
   ;                                ns:discount  0.25 
   .
</programlisting></listitem>
<listitem>Upload the file to DAV -- <programlisting>% curl --verbose -iX PUT -d @temp/ldp-books.ttl -u dav:dav -H &#39;Content-Type: text/turtle&#39; http://example.com/DAV/test4.ttl   &gt; ldp/ldp5.log
</programlisting></listitem>
<listitem>The server&#39;s response should resemble the following -- <programlisting>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: &lt;&gt;;rel=&lt;http://www.w3.org/ns/ldp/Resource&gt;
Content-Length: 172

&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML 2.0//EN&quot;&gt;
  &lt;HTML&gt;
    &lt;HEAD&gt;
      &lt;TITLE&gt;201 Created&lt;/TITLE&gt;
    &lt;/HEAD&gt;
    &lt;BODY&gt;
      &lt;H1&gt;Created&lt;/H1&gt;Resource /DAV/test4.ttl has been created.
    &lt;/BODY&gt;
  &lt;/HTML&gt;
</programlisting></listitem>
</orderedlist><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> Related</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="http://www.w3.org/TR/ldp/">Linked Data Platform 1.0</ulink> </listitem>
<listitem><ulink url="VirtGraphProtocolCURLExamples">SPARQL 1.1. Graph Store HTTP Protocol cURL Examples Collection</ulink> </listitem>
<listitem><ulink url="VirtGraphUpdateProtocol">Manage RDF data by using SPARQL 1.1. Graph Store HTTP Protocol</ulink> </listitem>
<listitem><ulink url="VirtRWWInteractionACLcURL">RWW Interaction &amp; ACL Testing using cURL</ulink> </listitem>
<listitem><ulink url="VirtuosoLDPSimpleCurlExamples">LDP in Virtuoso - Simple Curl Examples</ulink> </listitem>
</itemizedlist></section></docbook>