Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 71d40963b505df4524269198e237b3e3 > files > 847

virtuoso-opensource-doc-6.1.4-2.fc14.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 <head profile="http://internetalchemy.org/2003/02/profile">
  <link rel="foaf" type="application/rdf+xml" title="FOAF" href="http://www.openlinksw.com/dataspace/uda/about.rdf" />
  <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" />
  <meta name="dc.title" content="14. RDF Data Access and Data Management" />
  <meta name="dc.subject" content="14. RDF Data Access and Data Management" />
  <meta name="dc.creator" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="dc.copyright" content="OpenLink Software, 1999 - 2009" />
  <link rel="top" href="index.html" title="OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="search" href="/doc/adv_search.vspx" title="Search OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="parent" href="rdfandsparql.html" title="Chapter Contents" />
  <link rel="prev" href="rdfviewsenterpr.html" title="Examples of Linked Data Views" />
  <link rel="next" href="virtuososponger.html" title="RDFizer Middleware (Sponger)" />
  <link rel="shortcut icon" href="../images/misc/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" type="text/css" href="doc.css" />
  <link rel="stylesheet" type="text/css" href="/doc/translation.css" />
  <title>14. RDF Data Access and Data Management</title>
  <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
  <meta name="author" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="copyright" content="OpenLink Software, 1999 - 2009" />
  <meta name="keywords" content="" />
  <meta name="GENERATOR" content="OpenLink XSLT Team" />
 </head>
 <body>
  <div id="header">
    <a name="rdfinsertmethods" />
    <img src="../images/misc/logo.jpg" alt="" />
    <h1>14. RDF Data Access and Data Management</h1>
  </div>
  <div id="navbartop">
   <div>
      <a class="link" href="rdfandsparql.html">Chapter Contents</a> | <a class="link" href="rdfviewsenterpr.html" title="Examples of Linked Data Views">Prev</a> | <a class="link" href="virtuososponger.html" title="RDFizer Middleware (Sponger)">Next</a>
   </div>
  </div>
  <div id="currenttoc">
   <form method="post" action="/doc/adv_search.vspx">
    <div class="search">Keyword Search: <br />
        <input type="text" name="q" /> <input type="submit" name="go" value="Go" />
    </div>
   </form>
   <div>
      <a href="http://www.openlinksw.com/">www.openlinksw.com</a>
   </div>
   <div>
      <a href="http://docs.openlinksw.com/">docs.openlinksw.com</a>
   </div>
    <br />
   <div>
      <a href="index.html">Book Home</a>
   </div>
    <br />
   <div>
      <a href="contents.html">Contents</a>
   </div>
   <div>
      <a href="preface.html">Preface</a>
   </div>
    <br />
   <div class="selected">
      <a href="rdfandsparql.html">RDF Data Access and Data Management</a>
   </div>
    <br />
   <div>
      <a href="rdfdatarepresentation.html">Data Representation</a>
   </div>
   <div>
      <a href="rdfsparql.html">SPARQL</a>
   </div>
   <div>
      <a href="sparqlextensions.html">Extensions</a>
   </div>
   <div>
      <a href="rdfgraphsecurity.html">RDF Graphs Security</a>
   </div>
   <div>
      <a href="rdfviews.html">Linked Data Views over RDBMS Data Source</a>
   </div>
   <div>
      <a href="rdfrdfviewgnr.html">Automated Generation of RDF Views over Relational Data Sources</a>
   </div>
   <div>
      <a href="rdfviewsenterpr.html">Examples of Linked Data Views</a>
   </div>
   <div class="selected">
      <a href="rdfinsertmethods.html">RDF Insert Methods in Virtuoso</a>
    <div>
        <a href="#rdfinsertmethodsapifunct" title="Using API functions">Using API functions</a>
        <a href="#rdfinsertmethodshttppost" title="SPARQL endpoint REST API">SPARQL endpoint REST API</a>
        <a href="#rdfinsertmethodshttpput" title="HTTP PUT using Content-Type: application/rdf+xml">HTTP PUT using Content-Type: application/rdf+xml</a>
        <a href="#rdfinsertmethodsload" title="SPARQL Insert using LOAD">SPARQL Insert using LOAD</a>
        <a href="#rdfindertmethodsparqlendpoint" title="SPARQL Insert via /sparql endpoint">SPARQL Insert via /sparql endpoint</a>
        <a href="#rdfinsertmethodsparqlqueryandodswiki" title="SPARQL Insert via SPARQL endpoint REST API and ODS wiki">SPARQL Insert via SPARQL endpoint REST API and ODS wiki</a>
        <a href="#rdfinsertmethodwebdav" title="Using WebDAV">Using WebDAV</a>
        <a href="#rdfinsertmethodvirtuosocrawler" title="Using Virtuoso Crawler">Using Virtuoso Crawler</a>
        <a href="#rdfinsertmethodsparqlqueryandsponger" title="Using SPARQL Query and Sponger (i.e. we Sponge the Resources in the FROM Clause or values for the graph-uri parameter in SPARQL protocol URLs)">Using SPARQL Query and Sponger (i.e. we Sponge the Resources in the FROM Clause or values for the graph-uri parameter in SPARQL protocol URLs)</a>
        <a href="#rdfinsertmethodplapis" title="Using Virtuoso PL APIs">Using Virtuoso PL APIs</a>
        <a href="#rdfinsertmethodsimilerdfbankapi" title="Using SIMILE RDF Bank API">Using SIMILE RDF Bank API</a>
        <a href="#rdfinsertmethodrdfnet" title="Using RDF NET">Using RDF NET</a>
        <a href="#rdfinsertmethodproxy" title="Using the RDF Proxy (Sponger) Service">Using the RDF Proxy (Sponger) Service</a>
    </div>
   </div>
   <div>
      <a href="virtuososponger.html">RDFizer Middleware (Sponger)</a>
   </div>
   <div>
      <a href="virtuosospongerfacetinstall.html">Virtuoso Faceted Browser Installation and configuration</a>
   </div>
   <div>
      <a href="virtuosospongerfacent.html">Virtuoso Faceted Web Service</a>
   </div>
   <div>
      <a href="rdfiridereferencing.html">Linked Data</a>
   </div>
   <div>
      <a href="rdfsparqlrule.html">Inference Rules &amp; Reasoning</a>
   </div>
   <div>
      <a href="rdfsparqlgeospat.html">RDF and Geometry</a>
   </div>
   <div>
      <a href="rdfperformancetuning.html">RDF Performance Tuning</a>
   </div>
   <div>
      <a href="rdfnativestorageproviders.html">RDF Data Access Providers (Drivers)</a>
   </div>
   <div>
      <a href="rdfgraphreplication.html">RDF Graph Replication</a>
   </div>
    <br />
  </div>
  <div id="text">
    <a name="rdfinsertmethods" />
    <h2>14.8. RDF Insert Methods in Virtuoso</h2>
    <a name="rdfinsertmethodsapifunct" />
    <h3>14.8.1. Using API functions</h3>
      <ul>
        <li>
        <a href="rdfsparql.html#rdfapidataimportttlp">Using the DB.DBA.TTLP() function</a>
          <ul>
            <li>Note: use this function for loading Turtle</li>
           </ul>
</li>
        <li>
        <a href="rdfsparql.html#rdfapidataimportttlpmt">Using the DB.DBA.TTLP_MT() function</a>
          <ul>
            <li>Note: use this function for loading triples from file on multiple threads</li>
           </ul>
</li>
        <li>
        <a href="rdfsparql.html#rdfapidataimportxmlttlpmt">Using the DB.DBA.RDF_LOAD_RDFXML_MT() function</a>
          <ul>
            <li>Note: Use this function for loading large resources when transactional integrity is not important (loading of a single resource may take more than one transaction)</li>
           </ul>
</li>
        <li>
        <a href="rdfsparql.html#rdfapidataimportttlphash">Using the DB.DBA.RDF_TTL2HASH() function</a>
    <ul>
            <li>Note: use this function to get dictionary of triples in &#39;long valmode&#39;.</li>
    </ul>
</li>
        <li>
        <a href="rdfsparql.html#rdfapidataimportloadrdfxml">Using the DB.DBA.RDF_LOAD_RDFXML() function</a>
          <ul>
            <li>For loading RDF/XML, the best way is to split the data to be loaded into
multiple streams and load these in parallel using this function.</li>
           </ul>
</li>
      </ul>
      <p>See <a href="rdfperformancetuning.html#rdfperfloading">more details</a> for loading Performance Tuning specifics.</p>
    <br />
    <a name="rdfinsertmethodshttppost" />
    <h3>14.8.2. SPARQL endpoint REST API</h3>
	<p>With POST can be accomplished SPARQL Insert/Update etc.</p>
	<p>The result is in the rdf_quad.</p>
	<p>With GET Methods you can get the triples which are saved.</p>
        <p>
      <strong>Examples:</strong>
    </p>
        <p>
      <strong>Example 1:</strong>
    </p>
        <p>Create a DAV collection xx for user demo with password demo.</p>
        <p>Execute the following command:</p>
<div>
      <pre class="programlisting">
curl -i -d &quot;INSERT {&lt;http://demo.openlinksw.com/DAV/home/demo_about.rdf&gt;
&lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt; &lt;http://rdfs.org/sioc/ns#User&gt;}&quot; -u &quot;demo:demo&quot;
-H &quot;Content-Type: application/sparql-query&quot; http://localhost:8890/DAV/xx/yy
</pre>
    </div>
        <p>The response should be:</p>
<div>
      <pre class="programlisting">
HTTP/1.1 201 Created
Server: Virtuoso/05.00.3023 (Win32) i686-generic-win-32  VDB
Connection: Keep-Alive
Content-Type: text/html; charset=ISO-8859-1
Date: Fri, 28 Dec 2007 12:50:12 GMT
Accept-Ranges: bytes
MS-Author-Via: SPARQL
Content-Length: 0
</pre>
    </div>
        <p>The result in the DAV/xx location will be a new WebDAV resource with name &quot;yy&quot; containing the inserted RDF:</p>
<div>
      <pre class="programlisting">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;rdf:RDF xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot;
xmlns:rdfs=&quot;http://www.w3.org/2000/01/rdf-schema#&quot;&gt;
&lt;rdf:Description
rdf:about=&quot;http://demo.openlinksw.com/DAV/home/demo_about.rdf&quot;&gt;
&lt;ns0pred:type xmlns:ns0pred=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot;
rdf:resource=&quot;http://rdfs.org/sioc/ns#User&quot;/&gt;
&lt;/rdf:Description&gt;
&lt;/rdf:RDF&gt;
</pre>
    </div>
        <p>
      <strong>Example 2:</strong>
    </p>
        <p>Create a DAV collection, for ex. with name &quot;test&quot; for user ( for ex. demo).</p>
        <p>Execute the following command:</p>
<div>
      <pre class="programlisting">
curl -i -d &quot;INSERT IN GRAPH &lt;http://mygraph.com&gt;
{ &lt;http://www.openlinksw.com/dataspace/kidehen@openlinksw.com#this&gt;
  &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt;
  &lt;http://rdfs.org/sioc/ns#User&gt; .
  &lt;http://www.openlinksw.com/dataspace/kidehen@openlinksw.com#this&gt;
  &lt;http://www.w3.org/2000/01/rdf-schema#label&gt;
  &lt;Kingsley Uyi Idehen&gt; .
  &lt;http://www.openlinksw.com/dataspace/kidehen@openlinksw.com#this&gt;
  &lt;http://rdfs.org/sioc/ns#creator_of&gt;

&lt;http://www.openlinksw.com/dataspace/kidehen@openlinksw.com/weblog/kidehen@openlinksw.com%27s%20BLOG%20%5B127%5D/1300&gt;
  } &quot; -u &quot;demo:demo&quot; -H &quot;Content-Type: application/sparql-query&quot; http://localhost:8890/DAV/home/demo/test/myrq
</pre>
    </div>
        <p>As result the response will be:</p>
<div>
      <pre class="programlisting">
HTTP/1.1 201 Created
Server: Virtuoso/05.00.3023 (Win32) i686-generic-win-32  VDB
Connection: Keep-Alive
Content-Type: text/html; charset=ISO-8859-1
Date: Thu, 20 Dec 2007 16:25:25 GMT
Accept-Ranges: bytes
MS-Author-Via: SPARQL
Content-Length: 0
</pre>
    </div>
        <p>Now let&#39;s check the inserted triples. Go to the sparql endpoint, i.e. http://localhost:8890/sparql and:</p>
<ul>
<li>Enter for Default Graph URI:
<div>
          <pre class="programlisting">
http://mygraph.com
</pre>
        </div>
   </li>
<li>Enter in the Query area:
<div>
          <pre class="programlisting">
SELECT * WHERE {?s ?p ?o}
</pre>
        </div>
   </li>
<li>Click the button &quot;Run Query&quot;</li>
<li>As result will be shown the inserted triples:
<div>
          <pre class="programlisting">
s  	                                                          p                                                 o
http://www.openlinksw.com/dataspace/kidehen@openlinksw.com#this   http://www.w3.org/1999/02/22-rdf-syntax-ns#type   http://rdfs.org/sioc/ns#User
http://www.openlinksw.com/dataspace/kidehen@openlinksw.com#this   http://www.w3.org/2000/01/rdf-schema#label 	    Kingsley
http://www.openlinksw.com/dataspace/kidehen@openlinksw.com#this   http://rdfs.org/sioc/ns#creator_of                http://www.openlinksw.com/dataspace/kidehen@openlinksw.com/weblog/kidehen@openlinksw.com%27s%20BLOG%20%5B127%5D/1300
</pre>
        </div>
   </li>
</ul>
<br />
     <a name="rdfinsertmethodshttpput" />
    <h3>14.8.3. HTTP PUT using Content-Type: application/rdf+xml</h3>
	<p>The URI in a PUT request identifies the entity enclosed with the request. Therefore using HTTP PUT is a more useful and meaningful command than using POST (which is more about submitting data to a script).</p>
        <p>
      <strong>Example:</strong>
    </p>
        <p>Suppose there is myfoaf.rdf file with the following content:</p>
<div>
      <pre class="programlisting">
&lt;rdf:RDF xmlns=&quot;http://www.example/jose/foaf.rdf#&quot;
    xmlns:foaf=&quot;http://xmlns.com/foaf/0.1/&quot;
    xmlns:log=&quot;http://www.w3.org/2000/10/swap/log#&quot;
    xmlns:myfoaf=&quot;http://www.example/jose/foaf.rdf#&quot;
    xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot;&gt;

    &lt;foaf:Person rdf:about=&quot;http://www.example/jose/foaf.rdf#jose&quot;&gt;
        &lt;foaf:homepage rdf:resource=&quot;http://www.example/jose/&quot;/&gt;
        &lt;foaf:knows rdf:resource=&quot;http://www.example/jose/foaf.rdf#juan&quot;/&gt;
        &lt;foaf:name&gt;Jose Jimen~ez&lt;/foaf:name&gt;
        &lt;foaf:nick&gt;Jo&lt;/foaf:nick&gt;
        &lt;foaf:workplaceHomepage rdf:resource=&quot;http://www.corp.example/&quot;/&gt;
    &lt;/foaf:Person&gt;

    &lt;foaf:Person rdf:about=&quot;http://www.example/jose/foaf.rdf#juan&quot;&gt;
        &lt;foaf:mbox rdf:resource=&quot;mailto:juan@mail.example&quot;/&gt;
    &lt;/foaf:Person&gt;

    &lt;foaf:Person rdf:about=&quot;http://www.example/jose/foaf.rdf#julia&quot;&gt;
        &lt;foaf:mbox rdf:resource=&quot;mailto:julia@mail.example&quot;/&gt;
    &lt;/foaf:Person&gt;

    &lt;rdf:Description rdf:about=&quot;http://www.example/jose/foaf.rdf#kendall&quot;&gt;
        &lt;foaf:knows rdf:resource=&quot;http://www.example/jose/foaf.rdf#edd&quot;/&gt;
    &lt;/rdf:Description&gt;
&lt;/rdf:RDF&gt;
</pre>
    </div>
        <p>Now let&#39;s upload the myfoaf.rdf file to destination server demo.openlinksw.com for user demo:</p>
<div>
      <pre class="programlisting">
curl -T myfoaf.rdf http://demo.openlinksw.com/DAV/home/demo/rdf_sink/myfoaf.rdf -u demo:demo
</pre>
    </div>
        <p>As result the response should be:</p>
<div>
      <pre class="programlisting">
&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/home/demo/rdf_sink/ myfoaf.rdf has been created.
&lt;/BODY&gt;
&lt;/HTML&gt;
</pre>
    </div>
    <p>Then you can execute:</p>
<div>
      <pre class="programlisting">
curl -F &quot;query=SELECT DISTINCT ?p FROM &lt;http://demo.openlinksw.com/DAV/home/demo/rdf_sink/&gt; WHERE {?s ?p ?o}&quot; http://demo.openlinksw.com/sparql
</pre>
    </div>
    <p>The result should be:</p>
<div>
      <pre class="programlisting">
&lt;?xml version=&quot;1.0&quot; ?&gt;
&lt;sparql xmlns=&quot;http://www.w3.org/2005/sparql-results#&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd&quot;&gt;
 &lt;head&gt;
  &lt;variable name=&quot;p&quot;/&gt;
 &lt;/head&gt;
 &lt;results distinct=&quot;false&quot; ordered=&quot;true&quot;&gt;
  &lt;result&gt;
   &lt;binding name=&quot;p&quot;&gt;&lt;uri&gt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&lt;/uri&gt;&lt;/binding&gt;
  &lt;/result&gt;
  &lt;result&gt;
   &lt;binding name=&quot;p&quot;&gt;&lt;uri&gt;http://xmlns.com/foaf/0.1/nick&lt;/uri&gt;&lt;/binding&gt;
  &lt;/result&gt;
  &lt;result&gt;
   &lt;binding name=&quot;p&quot;&gt;&lt;uri&gt;http://xmlns.com/foaf/0.1/name&lt;/uri&gt;&lt;/binding&gt;
  &lt;/result&gt;
  &lt;result&gt;
   &lt;binding name=&quot;p&quot;&gt;&lt;uri&gt;http://xmlns.com/foaf/0.1/homepage&lt;/uri&gt;&lt;/binding&gt;
  &lt;/result&gt;
  &lt;result&gt;
   &lt;binding name=&quot;p&quot;&gt;&lt;uri&gt;http://xmlns.com/foaf/0.1/knows&lt;/uri&gt;&lt;/binding&gt;
  &lt;/result&gt;
  &lt;result&gt;
   &lt;binding name=&quot;p&quot;&gt;&lt;uri&gt;http://xmlns.com/foaf/0.1/workplaceHomepage&lt;/uri&gt;&lt;/binding&gt;
  &lt;/result&gt;
  &lt;result&gt;
   &lt;binding name=&quot;p&quot;&gt;&lt;uri&gt;http://xmlns.com/foaf/0.1/mbox&lt;/uri&gt;&lt;/binding&gt;
  &lt;/result&gt;
 &lt;/results&gt;
&lt;/sparql&gt;
</pre>
    </div>
<p>Other examples with curl:</p>
<div>
      <pre class="programlisting">
curl -F &quot;query=SELECT distinct ?Concept FROM &lt;http://dbpedia.org&gt; WHERE {?s a ?Concept} limit 10&quot; http://dbpedia.org/sparql
</pre>
    </div>
<div>
      <pre class="programlisting">
curl -F &quot;query=SELECT distinct ?Concept FROM &lt;http://myopenlink.net/dataspace/person/kidehen&gt; WHERE {?s a ?Concept} limit 10&quot; http://demo.openlinksw.com/sparql
</pre>
    </div>
<div>
      <pre class="programlisting">
curl -F &quot;query=SELECT distinct ?Concept FROM &lt;http://data.openlinksw.com/oplweb/product_family/virtuoso&gt; WHERE {?s a ?Concept} limit 10&quot; http://demo.openlinksw.com/sparql
</pre>
    </div>
<div>
      <pre class="programlisting">
curl -F &quot;query=SELECT distinct ?Concept FROM &lt;http://openlinksw.com/dataspace/organization/openlink&gt; WHERE {?s a ?Concept} limit 10&quot; http://demo.openlinksw.com/sparql
</pre>
    </div>
    <br />
     <a name="rdfinsertmethodsload" />
    <h3>14.8.4. SPARQL Insert using LOAD</h3>
        <p>SPARQL INSERT operation can be done using the LOAD features:</p>
<div>
      <pre class="programlisting">        
	
SPARQL INSERT INTO &lt;..&gt; { .... } [[FROM ...] { ... }]
	
SPARQL LOAD &lt;x&gt; [INTO &lt;y&gt;]

-- &lt;ResourceURL&gt; will be the Graph IRI of the loaded data:
SPARQL LOAD &lt;ResourceURL&gt; 
	
</pre>
    </div> 
        <p>Examples:</p>               
<ol>
      <li>Load from ISQL:
<div>
          <pre class="programlisting">
SPARQL insert in graph &lt;http://mygraph.com&gt;
    {
  &lt;http://myopenlink.net/dataspace/Kingsley#this&gt;
  &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt;
  &lt;http://rdfs.org/sioc/ns#User&gt; .

  &lt;http://myopenlink.net/dataspace/Kingsley#this&gt;
  &lt;http://rdfs.org/sioc/ns#id&gt;
  &lt;Kingsley&gt; .

  &lt;http://myopenlink.net/dataspace/Caroline#this&gt;
  &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt;
  &lt;http://rdfs.org/sioc/ns#User&gt; .

 &lt;http://myopenlink.net/dataspace/Caroline#this&gt;
  &lt;http://rdfs.org/sioc/ns#id&gt;
  &lt;Caroline&gt; .

   &lt;http://myopenlink.net/dataspace/Matt#this&gt;
  &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt;
  &lt;http://rdfs.org/sioc/ns#User&gt; .

  &lt;http://myopenlink.net/dataspace/Matt#this&gt;
  &lt;http://rdfs.org/sioc/ns#id&gt;
  &lt;Matt&gt; .

   &lt;http://myopenlink.net/dataspace/demo#this&gt;
  &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt;
  &lt;http://rdfs.org/sioc/ns#User&gt; .

  &lt;http://myopenlink.net/dataspace/demo#this&gt;
  &lt;http://rdfs.org/sioc/ns#id&gt;
  &lt;demo&gt; .};
</pre>
        </div>
   </li>
      <li>Load from .rq file:
     <ul>
       <li>Create DAV collection which is visible to public, for ex: http://localhost:8890/DAV/tmp</li>
       <li>Upload to the DAV collection the following file for ex. with name listall.rq and with the following content:
<div>
              <pre class="programlisting">
SPARQL
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 sioc: &lt;http://rdfs.org/sioc/ns#&gt;
SELECT ?x ?p ?o
FROM &lt;http://mygraph.com&gt;
WHERE
       {
    ?x rdf:type sioc:User .
    ?x ?p ?o.
    ?x sioc:id ?id .
    FILTER REGEX(str(?id), &quot;^King&quot;)
  }
ORDER BY ?x
</pre>
            </div>
       </li>
       <li>Execute from ISQL the following command:
<div>
              <pre class="programlisting">
SQL&gt;SPARQL
load bif:concat (&quot;http://&quot;, bif:registry_get(&quot;URIQADefaultHost&quot;), &quot;/DAV/tmp/listall.rq&quot;) into graph &lt;http://myNewGraph.com&gt;;
</pre>
            </div>
        <p>As result should be shown:</p>
<div>
              <pre class="programlisting">
callret-0
VARCHAR
_______________________________________________________________________________

Load &lt;http://localhost:8890/DAV/tmp/listall.rq&gt; into graph &lt;http://myNewGraph.com&gt; -- done

1 Rows. -- 321 msec.
</pre>
            </div>
       </li>       
     </ul>	
   </li>
      <li>Load from Resource URL:
<div>
          <pre class="programlisting">   	
SQL&gt; SPARQL LOAD &lt;http://www.w3.org/People/Berners-Lee/card#i&gt;;
callret-0
VARCHAR
_______________________________________________________________________________

Load &lt;http://www.w3.org/People/Berners-Lee/card#i&gt; into graph &lt;http://www.w3.org/People/Berners-Lee/card#i&gt; -- done

1 Rows. -- 703 msec.
SQL&gt;

</pre>
        </div>	
   </li>
    </ol>
    <br />
     <a name="rdfindertmethodsparqlendpoint" />
    <h3>14.8.5. SPARQL Insert via /sparql endpoint</h3>
        <p>SPARQL INSERT operation can be sent to a web service endpoint as a single statement and executed in sequence.</p>
        <p>
      <strong>Example:</strong>
    </p>
        <p>Using the Virtuoso ISQL tool or using the /sparql UI at http://host:port/sparql, execute the following:</p>
<ul>
<li>Insert into graph http://BookStore.com 3 triples:
<div>
          <pre class="programlisting">
SQL&gt;SPARQL insert in graph &lt;http://BookStore.com&gt;
{ &lt;http://www.dajobe.org/foaf.rdf#i&gt; &lt;http://purl.org/dc/elements/1.1/date&gt; &lt;1999-04-01T00:00:00&gt; .
  &lt;http://www.w3.org/People/Berners-Lee/card#i&gt; &lt;http://purl.org/dc/elements/1.1/date&gt; &lt;1998-05-03T00:00:00&gt; .
  &lt;http://www.w3.org/People/Connolly/#me&gt; &lt;http://purl.org/dc/elements/1.1/date&gt; &lt;2001-02-08T00:00:00&gt; };
</pre>
        </div>
   </li>
<li>As result will be shown the message:
<div>
          <pre class="programlisting">
SQL&gt;Insert into &lt;http://BookStore.com&gt;
3 triples -- done
</pre>
        </div>
   </li>
<li>Next we will select all triples from the graph http://BookStore.com:
<div>
          <pre class="programlisting">
SQL&gt;SPARQL SELECT * FROM &lt;http://BookStore.com&gt; WHERE {?s ?p ?o};
</pre>
        </div>
   </li>
<li>As result will be shown:
<div>
          <pre class="programlisting">
s                                              p                                       o
VARCHAR                                        VARCHAR                                 VARCHAR
_______________________________________________________________________________

http://www.w3.org/People/Berners-Lee/card#i    http://purl.org/dc/elements/1.1/date    1998-05-03T00:00:00
http://www.w3.org/People/Connolly/#me          http://purl.org/dc/elements/1.1/date    2001-02-08T00:00:00
http://www.dajobe.org/foaf.rdf#i               http://purl.org/dc/elements/1.1/date    1999-04-01T00:00:00

3 Rows. -- 0 msec.

</pre>
        </div>
   </li>
<li>Now let&#39;s insert into graph another http://NewBookStore.com graph&#39;s values:
<div>
          <pre class="programlisting">
SQL&gt;SPARQL
PREFIX dc:  &lt;http://purl.org/dc/elements/1.1/&gt;
PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;
INSERT INTO GRAPH &lt;http://NewBookStore.com&gt; { ?book ?p ?v }
WHERE
  { GRAPH  &lt;http://BookStore.com&gt;
   { ?book dc:date ?date
     FILTER ( xsd:dateTime(?date) &lt; xsd:dateTime(&quot;2000-01-01T00:00:00&quot;)).
     ?book ?p ?v.
   }
  };
</pre>
        </div>
   </li>
<li>As result will be shown:
<div>
          <pre class="programlisting">
callret-0
VARCHAR
_______________________________________________________________________________

Insert into &lt;http://NewBookStore.com&gt;, 2 triples -- done
</pre>
        </div>
   </li>
<li>Finally we will check the triples from the graph NewBookStore.com:
<div>
          <pre class="programlisting">
SQL&gt; SPARQL
SELECT *
FROM &lt;http://NewBookStore.com&gt;
WHERE {?s ?p ?o};
</pre>
        </div>
   </li>
<li>As result will be shown:
<div>
          <pre class="programlisting">
s                                             p                                      o
VARCHAR                                       VARCHAR                                VARCHAR
_______________________________________________________________________________

http://www.w3.org/People/Berners-Lee/card#i   http://purl.org/dc/elements/1.1/date   1998-05-03T00:00:00
http://www.dajobe.org/foaf.rdf#i              http://purl.org/dc/elements/1.1/date   1999-04-01T00:00:00

2 Rows. -- 10 msec.
</pre>
        </div>
   </li>
</ul>
<br />
     <a name="rdfinsertmethodsparqlqueryandodswiki" />
    <h3>14.8.6. SPARQL Insert via SPARQL endpoint REST API and ODS wiki</h3>
        <p>With HTTP Post and ODS wiki can be written an rdf document and respectively to be performed over it INSERT/UPDATE action.</p>
        <p>You can write to a file using SIOC terms for ODS-Wiki</p>
        <p>You can check with sparql the inserted / updated triples in the Quad Store.</p>
        <p>
      <strong>Example:</strong>
    </p>
        <p>Suppose there is ODS user test3 with ODS password 1, which has testWiki wiki instance.</p>
        <p>Execute the following:</p>
<div>
      <pre class="programlisting">
curl -i -d &quot;INSERT {&lt;http://localhost:8890/dataspace/test3/wiki/testWiki&gt; &lt;http://atomowl.org/ontologies/atomrdf#contains&gt; &lt;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&gt; . &lt;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&gt; &lt;http://rdfs.org/sioc/ns#has_container&gt; &lt;http://localhost:8890/dataspace/test3/wiki/testWiki&gt; . &lt;http://localhost:8890/dataspace/test3/wiki/testWiki&gt; &lt;http://atomowl.org/ontologies/atomrdf#entry&gt; &lt;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&gt; . &lt;http://localhost:8890/dataspace/test3/wiki/testWiki&gt; &lt;http://rdfs.org/sioc/ns#container_of&gt; &lt;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&gt; . &lt;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&gt; &lt;http://rdfs.org/sioc/ns#topic&gt;  &lt;http://localhost:8890/dataspace/test3/wiki/testWiki&gt; . &lt;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&gt; &lt;http://atomowl.org/ontologies/atomrdf#source&gt; &lt;http://localhost:8890/dataspace/test3/wiki/testWiki&gt; . &lt;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&gt; &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt; &lt;http://rdfs.org/sioc/types#Comment&gt; . &lt;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&gt; &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt; &lt;http://atomowl.org/ontologies/atomrdf#Entry&gt; . &lt;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&gt; &lt;http://www.w3.org/2000/01/rdf-schema#label&gt; &#39;MyTest&#39; . &lt;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&gt; &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt; &lt;http://atomowl.org/ontologies/atomrdf#Link&gt; . &lt;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&gt; &lt;http://rdfs.org/sioc/ns#content&gt; &lt;test&gt;}&quot; -u &quot;test3:1&quot; -H &quot;Content-Type: application/sparql-query&quot; http://localhost:8890/DAV/home/test3/wiki/testWiki/MyTest
</pre>
    </div>
        <p>As result we should have 2 files created:</p>
<ul>
<li>In the user DAV folder &quot;DAV/home/test3/wiki/testWiki/&quot; will be created a file &quot;MyTest&quot; with type &quot;application/sparql-query&quot;. You can view the content of this file from the Conductor UI or from the user&#39;s Briefcase UI, path &quot;DAV/home/test3/wiki/testWiki&quot;. Its content will be:
<div>
          <pre class="programlisting">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;rdf:RDF xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; xmlns:rdfs=&quot;http://www.w3.org/2000/01/rdf-schema#&quot;&gt;
&lt;rdf:Description rdf:about=&quot;http://localhost:8890/dataspace/test3/wiki/testWiki&quot;&gt;&lt;ns0pred:entry xmlns:ns0pred=&quot;http://atomowl.org/ontologies/atomrdf#&quot; rdf:resource=&quot;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&quot;/&gt;&lt;/rdf:Description&gt;
&lt;rdf:Description rdf:about=&quot;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&quot;&gt;&lt;ns0pred:label xmlns:ns0pred=&quot;http://www.w3.org/2000/01/rdf-schema#&quot;&gt;MyTest&lt;/ns0pred:label&gt;&lt;/rdf:Description&gt;
&lt;rdf:Description rdf:about=&quot;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&quot;&gt;&lt;ns0pred:type xmlns:ns0pred=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; rdf:resource=&quot;http://atomowl.org/ontologies/atomrdf#Link&quot;/&gt;&lt;/rdf:Description&gt;
&lt;rdf:Description rdf:about=&quot;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&quot;&gt;&lt;ns0pred:type xmlns:ns0pred=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; rdf:resource=&quot;http://rdfs.org/sioc/types#Comment&quot;/&gt;&lt;/rdf:Description&gt;
&lt;rdf:Description rdf:about=&quot;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&quot;&gt;&lt;ns0pred:type xmlns:ns0pred=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; rdf:resource=&quot;http://atomowl.org/ontologies/atomrdf#Entry&quot;/&gt;&lt;/rdf:Description&gt;
&lt;rdf:Description rdf:about=&quot;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&quot;&gt;&lt;ns0pred:has_container xmlns:ns0pred=&quot;http://rdfs.org/sioc/ns#&quot; rdf:resource=&quot;http://localhost:8890/dataspace/test3/wiki/testWiki&quot;/&gt;&lt;/rdf:Description&gt;
&lt;rdf:Description rdf:about=&quot;http://localhost:8890/dataspace/test3/wiki/testWiki&quot;&gt;&lt;ns0pred:container_of xmlns:ns0pred=&quot;http://rdfs.org/sioc/ns#&quot; rdf:resource=&quot;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&quot;/&gt;&lt;/rdf:Description&gt;
&lt;rdf:Description rdf:about=&quot;http://localhost:8890/dataspace/test3/wiki/testWiki&quot;&gt;&lt;ns0pred:contains xmlns:ns0pred=&quot;http://atomowl.org/ontologies/atomrdf#&quot; rdf:resource=&quot;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&quot;/&gt;&lt;/rdf:Description&gt;
&lt;rdf:Description rdf:about=&quot;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&quot;&gt;&lt;ns0pred:content xmlns:ns0pred=&quot;http://rdfs.org/sioc/ns#&quot;&gt;test&lt;/ns0pred:content&gt;&lt;/rdf:Description&gt;
&lt;rdf:Description rdf:about=&quot;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&quot;&gt;&lt;ns0pred:topic xmlns:ns0pred=&quot;http://rdfs.org/sioc/ns#&quot; rdf:resource=&quot;http://localhost:8890/dataspace/test3/wiki/testWiki&quot;/&gt;&lt;/rdf:Description&gt;
&lt;rdf:Description rdf:about=&quot;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&quot;&gt;&lt;ns0pred:source xmlns:ns0pred=&quot;http://atomowl.org/ontologies/atomrdf#&quot; rdf:resource=&quot;http://localhost:8890/dataspace/test3/wiki/testWiki&quot;/&gt;&lt;/rdf:Description&gt;
&lt;/rdf:RDF&gt;
</pre>
        </div>
   </li>
<li>To the user&#39;s wiki instance will be added a new WikiWord &quot;MyTest&quot; with content the value of the SIOC term attribute &quot;content&quot;:
<div>
          <pre class="programlisting">
&lt;http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest&gt; &lt;http://rdfs.org/sioc/ns#content&gt; &lt;test&gt;
i.e. the content will be &quot;test&quot;.
</pre>
        </div>
   </li>
</ul>
        <p>Now let&#39;s check what data was inserted in the Quad Store:</p>
<ul>
<li>Go to the sparql endpoint, i.e. for ex. to http://localhost:8890/sparql</li>
<li>Enter for Default Graph URI:
<div>
          <pre class="programlisting">
http://localhost:8890/DAV/home/test3/wiki/testWiki/MyTest
</pre>
        </div>
   </li>
<li>Enter for Query text:
<div>
          <pre class="programlisting">
SELECT * WHERE {?s ?p ?o}
</pre>
        </div>
   </li>
<li>Click the &quot;Run Query&quot; button.</li>
<li>As result will be shown the inserted triples:
<div>
          <pre class="programlisting">
s  	                                                    p  	                                             o
http://localhost:8890/dataspace/test3/wiki/testWiki 	    http://rdfs.org/sioc/ns#container_of 	     http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest
http://localhost:8890/dataspace/test3/wiki/testWiki 	    http://atomowl.org/ontologies/atomrdf#entry      http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest
http://localhost:8890/dataspace/test3/wiki/testWiki 	    http://atomowl.org/ontologies/atomrdf#contains   http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest
http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest  http://www.w3.org/1999/02/22-rdf-syntax-ns#type  http://rdfs.org/sioc/types#Comment
http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest  http://www.w3.org/1999/02/22-rdf-syntax-ns#type  http://atomowl.org/ontologies/atomrdf#Entry
http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest  http://www.w3.org/1999/02/22-rdf-syntax-ns#type  http://atomowl.org/ontologies/atomrdf#Link
http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest  http://www.w3.org/2000/01/rdf-schema#label 	     MyTest
http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest  http://rdfs.org/sioc/ns#has_container 	     http://localhost:8890/dataspace/test3/wiki/testWiki
http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest  http://rdfs.org/sioc/ns#content 	             test
http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest  http://rdfs.org/sioc/ns#topic 	             http://localhost:8890/dataspace/test3/wiki/testWiki
http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest  http://atomowl.org/ontologies/atomrdf#source     http://localhost:8890/dataspace/test3/wiki/testWiki
</pre>
        </div>
   </li>
</ul>
    <br />
    
      <a name="rdfinsertmethodwebdav" />
    <h3>14.8.7. Using WebDAV</h3>
      <p> Example using WebDAV (mount folder to DAV and dump; if this is the rdf_sink
the Quad Store is updated automatically, or you can load from DAV manually to quad store)</p>
      <p>
      <strong>Example:</strong>
    </p>
      <p>
      <strong>Example 1: Using ODS Briefcase</strong>
    </p>
      <ul>
        <li>Go to your ods location, for ex. http://localhost:8890/ods</li>
        <li>Register user, for ex. user test1</li>
        <li>Login if not already in ods</li>
        <li>Go to ODS -&gt; Briefcase</li>
        <li>Go to ODS -&gt; Briefcase</li>
        <li>Click the &quot;New folder&quot; icon from the Main Briefcase horizontal navigation</li>
        <li>Enter for name for ex. &quot;mytest&quot; and click the &quot;Create&quot; button.
          <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Using Briefcase UI" src="../images/ui/uc6.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 14.8.7.1. Using Briefcase UI</td>
      </tr>
        </table>
   </li>
        <li>Go to folder &quot;mytest&quot; and click the click the &quot;Upload&quot; icon from the Main Briefcase horizontal navigation</li>
        <li>Enter for name for ex. &quot;mytest&quot; and click the &quot;Create&quot; button.
          <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Using Briefcase UI" src="../images/ui/uc7.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 14.8.7.1. Using Briefcase UI</td>
      </tr>
        </table>
</li>
        <li>In the shown form set:
          <ul>
            <li>Destination: RDF Store</li>
            <li>RDF graph name for ex. with the value: http://localhost:8890/DAV/home/test2/mytest/</li>
            <li>Select URL or File. For ex. you can select the following file with name jose.rdf:
<div>
              <pre class="programlisting">
&lt;rdf:RDF xmlns=&quot;http://www.example/jose/foaf.rdf#&quot;
    xmlns:foaf=&quot;http://xmlns.com/foaf/0.1/&quot;
    xmlns:log=&quot;http://www.w3.org/2000/10/swap/log#&quot;
    xmlns:myfoaf=&quot;http://www.example/jose/foaf.rdf#&quot;
    xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot;&gt;

    &lt;foaf:Person rdf:about=&quot;http://www.example/jose/foaf.rdf#jose&quot;&gt;
        &lt;foaf:homepage rdf:resource=&quot;http://www.example/jose/&quot;/&gt;
        &lt;foaf:knows rdf:resource=&quot;http://www.example/jose/foaf.rdf#juan&quot;/&gt;
        &lt;foaf:name&gt;Jose Jimen~ez&lt;/foaf:name&gt;
        &lt;foaf:nick&gt;Jo&lt;/foaf:nick&gt;
        &lt;foaf:workplaceHomepage rdf:resource=&quot;http://www.corp.example/&quot;/&gt;
    &lt;/foaf:Person&gt;

    &lt;foaf:Person rdf:about=&quot;http://www.example/jose/foaf.rdf#juan&quot;&gt;
        &lt;foaf:mbox rdf:resource=&quot;mailto:juan@mail.example&quot;/&gt;
    &lt;/foaf:Person&gt;

    &lt;foaf:Person rdf:about=&quot;http://www.example/jose/foaf.rdf#julia&quot;&gt;
        &lt;foaf:mbox rdf:resource=&quot;mailto:julia@mail.example&quot;/&gt;
    &lt;/foaf:Person&gt;

    &lt;rdf:Description rdf:about=&quot;http://www.example/jose/foaf.rdf#kendall&quot;&gt;

        &lt;foaf:knows rdf:resource=&quot;http://www.example/jose/foaf.rdf#edd&quot;/&gt;
    &lt;/rdf:Description&gt;
&lt;/rdf:RDF&gt;
</pre>
            </div>
            </li>
</ul>
</li>
        <li>You can also perform the steps from above by uploading the file in the rdf_sink
folder i.e. in Briefcase it will be with this path: DAV/home/test2/rdf_sink and respectively the &quot;RDF graph name&quot;
will have this value: http://host:port/DAV/home/username/rdf_sink/</li>
      </ul>
      <p>Execute from ISQL or from the SPARQL endpoint the following query:</p>
<div>
      <pre class="programlisting">
SELECT * FROM &lt;http://localhost:8890/DAV/home/test2/mytest/&gt;
WHERE {?s ?p ?o}
</pre>
    </div>
      <p>As result should be shown:</p>
<div>
      <pre class="programlisting">
s  	                                  p  	                                            o
http://www.example/jose/foaf.rdf#jose 	  http://www.w3.org/1999/02/22-rdf-syntax-ns#type   http://xmlns.com/foaf/0.1/Person
http://www.example/jose/foaf.rdf#jose 	  http://xmlns.com/foaf/0.1/nick 	            Jo
http://www.example/jose/foaf.rdf#jose 	  http://xmlns.com/foaf/0.1/name 	            Jose Jimen~ez
http://www.example/jose/foaf.rdf#jose 	  http://xmlns.com/foaf/0.1/knows 	            http://www.example/jose/foaf.rdf#juan
http://www.example/jose/foaf.rdf#jose 	  http://xmlns.com/foaf/0.1/homepage 	            http://www.example/jose/
http://www.example/jose/foaf.rdf#jose 	  http://xmlns.com/foaf/0.1/workplaceHomepage 	    http://www.corp.example/
http://www.example/jose/foaf.rdf#kendall  http://xmlns.com/foaf/0.1/knows 	            http://www.example/jose/foaf.rdf#edd
http://www.example/jose/foaf.rdf#julia 	  http://www.w3.org/1999/02/22-rdf-syntax-ns#type   http://xmlns.com/foaf/0.1/Person
http://www.example/jose/foaf.rdf#julia 	  http://xmlns.com/foaf/0.1/mbox 	            mailto:julia@mail.example
http://www.example/jose/foaf.rdf#juan 	  http://www.w3.org/1999/02/22-rdf-syntax-ns#type   http://xmlns.com/foaf/0.1/Person
http://www.example/jose/foaf.rdf#juan 	  http://xmlns.com/foaf/0.1/mbox 	            mailto:juan@mail.example
</pre>
    </div>
      <p>
      <strong>Example 2: Using Conductor UI</strong>
    </p>
      <ul>
        <li>Go to Conductor UI, for ex. at http://localhost:8890/conductor</li>
        <li>Login as dba user</li>
        <li>Go to Linked Data -&gt; Quad Store Upload
          <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Quad Store Upload" src="../images/ui/uc1.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 14.8.7.1. Quad Store Upload</td>
      </tr>
        </table>
  </li>
        <li>In the shown form click the &quot;Browse&quot; button in order to select a file, for ex. 
        	the file jose.rdf and set the &quot;RDF IRI*&quot;
          <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Quad Store Upload" src="../images/ui/uc2.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 14.8.7.1. Quad Store Upload</td>
      </tr>
        </table>
  </li>
         <li>Click the &quot;Upload&quot; button.
          <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Quad Store Upload" src="../images/ui/uc3.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 14.8.7.1. Quad Store Upload</td>
      </tr>
        </table>         	
         	</li>
      </ul>
    <br />
    
      <a name="rdfinsertmethodvirtuosocrawler" />
    <h3>14.8.8. Using Virtuoso Crawler</h3>
      <p>Using Virtuoso Crawler (which includes the Sponger options so you crawl
non-RDF but get RDF and this can go to the Quad Store)</p>
      <p>
      <strong>Example:</strong>
    </p>
      <p>Go to Conductor UI. For ex. at http://localhost:8890/conductor</p>
      <p>Login as dba user</p>
      <p>Go to tab Web Application Server</p>
      <p>Go to tab Content Imports</p>
      <p>Click the &quot;New Target&quot; button</p>
      <p>In the shown form:</p>
      <ul>
        <li>Enter for &quot;Target description&quot;: Tim Berners-Lee&#39;s electronic Business Card</li>
        <li>Enter for &quot;Target URL&quot;: http://www.w3.org/People/Berners-Lee/</li>
        <li>Enter for &quot;Copy to local DAV collection&quot; for ex.: /DAV/home/demo/rdf_sink/</li>
        <li>Choose from the list &quot;Local resources owner&quot;: demo</li>
        <li>Check the check.box with label &quot;Store metadata&quot;.</li>
        <li>Check all the check-boxes shown below the check-box &quot;Store metadata&quot;.</li>
        <li>Note: when selected &quot;Convert Link&quot;, then all HREFs in the local stored content will be relative.</li>
        <li>Click the button &quot;Create&quot;.
          <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Using Virtuoso Crawler" src="../images/ui/rdfinsert1.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 14.8.8.1. Using Virtuoso Crawler</td>
      </tr>
        </table>
        </li>
      </ul>
      <p>Click the button &quot;Import Queues&quot;.</p>
      <p>For &quot;Robot target&quot; with label &quot;Tim Berners-Lee&#39;s electronic Business Card&quot;
click the start link.</p>
      <p>As result should be shown the number of the pages retrieved.</p>
      <table class="figure" border="0" cellpadding="0" cellspacing="0">
    <tr>
     <td>
          <img alt="Using Virtuoso Crawler" src="../images/ui/rdfinsert2.png" />
     </td>
    </tr>
    <tr>
        <td>Figure: 14.8.8.1. Using Virtuoso Crawler</td>
    </tr>
    </table>
      <p>Now using the sparql endpoint with sponger option &quot;Use only local data&quot;
enter for Default Graph URI: http://www.w3.org/People/Berners-Lee and execute the following query: </p>
<div>
      <pre class="programlisting">
SELECT *
FROM &lt;http://www.w3.org/People/Berners-Lee&gt;
WHERE {?s ?p ?o}
</pre>
    </div>
      <p>As result should be shown the following triples:</p>
<div>
      <pre class="programlisting">
s                                       p  	                                            o
http://www.w3.org/People/Berners-Lee 	http://www.w3.org/1999/02/22-rdf-syntax-ns#type     http://xmlns.com/foaf/0.1/Document
http://www.w3.org/People/Berners-Lee 	http://purl.org/dc/elements/1.1/title 	            Answers for young people - Tim Berners-Lee
http://www.w3.org/People/Berners-Lee 	http://purl.org/dc/elements/1.1/title 	            Berners-Lee: Weaving the Web
http://www.w3.org/People/Berners-Lee 	http://purl.org/dc/elements/1.1/title 	            Declaration by Tim BL 28 Feb 1996 w.r.t. CDA challenge
http://www.w3.org/People/Berners-Lee 	http://purl.org/dc/elements/1.1/title 	            Errata - Berners-Lee: Weaving the Web
http://www.w3.org/People/Berners-Lee 	http://purl.org/dc/elements/1.1/title 	            Frequently asked questions by the Press - Tim BL
http://www.w3.org/People/Berners-Lee 	http://purl.org/dc/elements/1.1/title 	            Glossary - Weaving the Web - Berners-Lee
http://www.w3.org/People/Berners-Lee 	http://purl.org/dc/elements/1.1/title 	            Longer Bio for Tim Berners-Lee
http://www.w3.org/People/Berners-Lee 	http://purl.org/dc/elements/1.1/title 	            Michael Dertouzos has left us
http://www.w3.org/People/Berners-Lee 	http://purl.org/dc/elements/1.1/title 	            The Future of the Web and Europe
http://www.w3.org/People/Berners-Lee 	http://purl.org/dc/elements/1.1/title 	            The World Wide Web: Past, Present and Future
http://www.w3.org/People/Berners-Lee 	http://purl.org/dc/elements/1.1/title 	            The World Wide Web: A very short personal history
http://www.w3.org/People/Berners-Lee 	http://purl.org/dc/elements/1.1/title 	            Tim Berners-Lee
http://www.w3.org/People/Berners-Lee 	http://purl.org/dc/elements/1.1/title 	            Tim Berners-Lee - 3Com Founders chair
http://www.w3.org/People/Berners-Lee 	http://purl.org/dc/elements/1.1/title 	            Tim Berners-Lee: Disclosures
http://www.w3.org/People/Berners-Lee 	http://purl.org/dc/elements/1.1/title 	            Tim Berners-Lee: WWW and UU and I
http://www.w3.org/People/Berners-Lee 	http://purl.org/dc/elements/1.1/title 	            Tim Berners-Lee: WorldWideWeb, the first Web client
</pre>
    </div>
    <p>
      <strong>Example: Use of schedular to interface Virtuoso Quad Store with PTSW using the following program:</strong>
    </p>
<div>
      <pre class="programlisting">


create procedure PTSW_CRAWL ()
{
  declare xt, xp any;
  declare content, headers any;

  content := http_get (&#39;http://pingthesemanticweb.com/export/&#39;, headers);
  xt := xtree_doc (content);
  xp := xpath_eval (&#39;//rdfdocument/@url&#39;, xt, 0);
  foreach (any x in xp) do
    {
      x := cast (x as varchar);
      dbg_obj_print (x);
      {
	declare exit handler for sqlstate &#39;*&#39; {
	  log_message (sprintf (&#39;PTSW crawler can not load : %s&#39;, x));
	};
        sparql load ?:x into graph ?:x;
	update DB.DBA.SYS_HTTP_SPONGE set HS_LOCAL_IRI = x, HS_EXPIRATION = null WHERE HS_LOCAL_IRI = &#39;destMD5=&#39; || md5 (x) || &#39;&amp;graphMD5=&#39; || md5 (x);
	commit work;
      }
    }
}
;

insert soft SYS_SCHEDULED_EVENT (SE_SQL, SE_START, SE_INTERVAL, SE_NAME)
	values (&#39;DB.DBA.PTSW_CRAWL ()&#39;, cast (stringtime (&#39;0:0&#39;) as DATETIME), 60, &#39;PTSW Crawling&#39;);
</pre>
    </div>
      <div class="tip">
      <div class="tiptitle">See Also:</div>
        <p>
        <a href="htmlconductorbar.html#contentcrawlerrdf">Other Methods to Set Up the Content Crawler for RDF gathering.</a>
      </p>
      </div>
    <br />
    
      <a name="rdfinsertmethodsparqlqueryandsponger" />
    <h3>14.8.9. Using SPARQL Query and Sponger (i.e. we Sponge the Resources in the FROM Clause or values for the graph-uri parameter in SPARQL protocol URLs)</h3>
      <p>
      <strong>Example:</strong>
    </p>
      <p>Execute the following query: </p>
<div>
      <pre class="programlisting">
SQL&gt;SPARQL
SELECT ?id
FROM NAMED &lt;http://www.openlinksw.com/dataspace/kidehen@openlinksw.com/weblog/kidehen@openlinksw.com%27s%20BLOG%20%5B127%5D/sioc.ttl&gt;
 OPTION (get:soft &quot;soft&quot;, get:method &quot;GET&quot;)
WHERE { GRAPH ?g { ?id a ?o } }
limit 10;
</pre>
    </div>
      <p>As result will be shown the retrieved triples:</p>
<div>
      <pre class="programlisting">
id
VARCHAR
_______________________________________________________________________________

http://www.openlinksw.com/dataspace/kidehen@openlinksw.com#this
http://www.openlinksw.com/dataspace/kidehen@openlinksw.com/weblog/kidehen@openlinksw.com%27s%20BLOG%20%5B127%5D
http://www.openlinksw.com/dataspace/kidehen@openlinksw.com/weblog/kidehen@openlinksw.com%27s%20BLOG%20%5B127%5D
http://www.openlinksw.com/dataspace/person/kidehen@openlinksw.com#this
http://www.openlinksw.com/dataspace/kidehen@openlinksw.com/weblog/kidehen@openlinksw.com%27s%20BLOG%20%5B127%5D/612
http://www.openlinksw.com/dataspace/kidehen@openlinksw.com/weblog/kidehen@openlinksw.com%27s%20BLOG%20%5B127%5D/612
http://www.openlinksw.com/dataspace/kidehen@openlinksw.com/weblog/kidehen@openlinksw.com%27s%20BLOG%20%5B127%5D/610
http://www.openlinksw.com/dataspace/kidehen@openlinksw.com/weblog/kidehen@openlinksw.com%27s%20BLOG%20%5B127%5D/610
http://www.openlinksw.com/dataspace/kidehen@openlinksw.com/weblog/kidehen@openlinksw.com%27s%20BLOG%20%5B127%5D/856
http://www.openlinksw.com/dataspace/kidehen@openlinksw.com/weblog/kidehen@openlinksw.com%27s%20BLOG%20%5B127%5D/856

10 Rows. -- 20 msec.
</pre>
    </div>
    <br />
    
      <a name="rdfinsertmethodplapis" />
    <h3>14.8.10. Using Virtuoso PL APIs</h3>
      <a name="rdfinsertmethodplapissimpleexample" />
    <h4>14.8.10.1. Basic Sponger Cartridge Example</h4>
      <p>In the example script we implement a basic mapper which maps a text/plain mime type
to an imaginary ontology, which extends the class Document from FOAF with properties &#39;txt:UniqueWords&#39;
and &#39;txt:Chars&#39;, where the prefix &#39;txt:&#39; we specify as &#39;urn:txt:v0.0:&#39;.</p>
<div>
      <pre class="programlisting">
use DB;

create procedure DB.DBA.RDF_LOAD_TXT_META
	(
	 in graph_iri varchar,
	 in new_origin_uri varchar,
	 in dest varchar,
         inout ret_body any,
	 inout aq any,
	 inout ps any,
	 inout ser_key any
	 )
{
  declare words, chars int;
  declare vtb, arr, subj, ses, str any;
  declare ses any;
  -- if any error we just say nothing can be done
  declare exit handler for sqlstate &#39;*&#39;
    {
      return 0;
    };
  subj := coalesce (dest, new_origin_uri);
  vtb := vt_batch ();
  chars := length (ret_body);
  -- using the text index procedures we get a list of words
  vt_batch_feed (vtb, ret_body, 1);
  arr := vt_batch_strings_array (vtb);
  -- the list has &#39;word&#39; and positions array , so we must divide by 2
  words := length (arr) / 2;
  ses := string_output ();
  -- we compose a N3 literal
  http (sprintf (&#39;&lt;%s&gt; &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt; &lt;http://xmlns.com/foaf/0.1/Document&gt; .\n&#39;, subj), ses);
  http (sprintf (&#39;&lt;%s&gt; &lt;urn:txt:v0.0:UniqueWords&gt; &quot;%d&quot; .\n&#39;, subj, words), ses);
  http (sprintf (&#39;&lt;%s&gt; &lt;urn:txt:v0.0:Chars&gt; &quot;%d&quot; .\n&#39;, subj, chars), ses);
  str := string_output_string (ses);
  -- we push the N3 text into the local store
  DB.DBA.TTLP (str, new_origin_uri, subj);
  return 1;
}
;

--
DELETE FROM DB.DBA.SYS_RDF_MAPPERS WHERE RM_HOOK = &#39;DB.DBA.RDF_LOAD_TXT_META&#39;;

INSERT SOFT DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
    VALUES (&#39;(text/plain)&#39;, &#39;MIME&#39;, &#39;DB.DBA.RDF_LOAD_TXT_META&#39;, null, &#39;Text Files (demo)&#39;);

-- here we set order to some large number so don&#39;t break existing mappers
update DB.DBA.SYS_RDF_MAPPERS set RM_ID = 2000 WHERE RM_HOOK = &#39;DB.DBA.RDF_LOAD_TXT_META&#39;;
</pre>
    </div>

<ol>
      <li>Paste the whole of this code into Conductor&#39;s iSQL interface and execute it to 
  	define and register the cartridge.</li>
      <li>Create a simple text document with a .txt extension. For ex. with name: summary.txt</li>
      <li>The .txt file must now be made Web accessible. A simple way to do this is to expose it as a WebDAV 
  	resource using Virtuoso&#39;s built-in WebDAV support:
    <ol>
          <li>Log in to Virtuoso&#39;s ODS Briefcase application;</li>
          <li>Navigate to your Public folder;</li>
          <li>Upload your text document, ensuring that the file extension is .txt, the MIME type is set to text/plain and the file permissions are rw-r--r--.</li>
          <li>As result the file would be Web accessible via the URL http://cname/DAV/home/username/Public/summary.txt .</li>
          <li>Note: you can also check our <a href="http://demo.openlinksw.com:8890/tutorial/hosting/ho_s_30/WebCalendar/tools/summary.txt">live demo</a>.</li>
        </ol>
  </li>
      <li>To test the mapper we just use /sparql endpoint with option &#39;Retrieve remote
RDF data for all missing source graphs&#39; to execute (for ex.):
<div>
          <pre class="programlisting">
SELECT *
FROM &lt;http://cname/DAV/home/username/Public/summary.txt&gt;
WHERE {?s ?p ?o}
</pre>
        </div>
  </li>
      <li>Click the &quot;Run Query&quot; button.</li>
      <li>As result should be shown the found triples, for ex.:
<div>
          <pre class="programlisting">
s  	                                                                    p  	                                            o
http://cname/DAV/home/username/Public/summary.txt  http://www.w3.org/1999/02/22-rdf-syntax-ns#type  http://xmlns.com/foaf/0.1/Document
http://cname/DAV/home/username/Public/summary.txt  urn:txt:v0.0:UniqueWords 	                      47
http://cname/DAV/home/username/Public/summary.txt  urn:txt:v0.0:Chars 	                            625
</pre>
        </div>
  </li>
    </ol>
      <p>
      <strong>Important: Setting Sponger Permissions</strong>
    </p>
      <p>In order to allow the Sponger to update the local RDF quad store with triples
constituting the sponged structured data, the role &quot;SPARQL_SPONGE&quot; must be granted to the
account &quot;SPARQL&quot;, i.e., to the owner account of /sparql web service endpoint.
This should normally be the case. If not, you must manually grant this
permission. As with most Virtuoso DBA tasks, the Conductor provides the simplest means of
doing this.</p>
  <div class="tip">
      <div class="tiptitle">See Also:</div>
    <ul>
      <li>The <a href="fn_rdf_load_rdfxml.html">DB.DBA.RDF_LOAD_RDFXML</a> function to
parse the content of RDF/XML text.</li>
      <li>The <a href="fn_ttlp_mt.html">DB.DBA.TTLP_MT</a> function to
parse TTL (TURTLE or N3 resource).</li>
      <li>The <a href="fn_gz_file_open.html">gz_file_open</a> function to
retrieve content of a gzipped file and example for loading gzipped N3 and Turtle files.</li>
    </ul>
  </div>
      <br />
    <br />
    
      <a name="rdfinsertmethodsimilerdfbankapi" />
    <h3>14.8.11. Using SIMILE RDF Bank API</h3>
      <p>Virtuoso implements the HTTP-based Semantic Bank API that enables client
applications to post to its RDF Triple Store. This method offers an alternative to
using Virtuoso/PL functions or WebDAV uploads as the triples-insertion mechanism.</p>
      <p>
      <strong>Example:</strong>
    </p>
      <p>From your machine go to Firefox-&gt;Tools-&gt;PiggyBank-&gt;My Semantic Bank Accounts</p>
      <p>Add in the shown form:</p>
      <ul>
        <li>For bank: address: http://demo.openlinksw.com/bank</li>
        <li>For account id: demo</li>
        <li>For password: demo</li>
      </ul>
      <p>Go to http://demo.openlinksw.com/ods</p>
      <p>Log in as user demo, password: demo</p>
      <p>Go to the Weblog tab from the main ODS Navigation</p>
      <p>Click on weblog instance name, for ex. &quot;demo&#39;s Weblog&quot;.</p>
      <p>When the weblog home page is loaded, click Alt + P.</p>
      <p>As result is shown the &quot;My PiggyBank&quot; page with all the collected information
presented in items.</p>
      <p>For several of the items add Tags from the form &quot;Tag&quot; shown for each of them.</p>
      <p>As result should be shown the message &quot;Last updated: [here goes the date value].</p>
      <p>You can also click &quot;Save&quot; and &quot;Publish&quot; for these items.</p>
      <p>Go to http://demo.openlinksw.com/sparql</p>
      <p>Enter for the &quot;Default Graph URI&quot; field: http://simile.org/piggybank/demo</p>
      <p>Enter for the &quot;Query text&quot; text-area:</p>
<div>
      <pre class="programlisting">
prefix rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;
prefix sioc: &lt;http://rdfs.org/sioc/ns#&gt;
SELECT *
FROM &lt;http://simile.org/piggybank/demo&gt;
WHERE {?s ?p  ?o}
</pre>
    </div>
      <p>Click &quot;Run Query&quot;.</p>
      <p>As results are shown the found results.</p>
    <br />
    
      <a name="rdfinsertmethodrdfnet" />
    <h3>14.8.12. Using RDF NET</h3>
      <p>
      <strong>Example:</strong>
    </p>
      <p>Execute the following query:</p>
<div>
      <pre class="programlisting">
SQL&gt; SELECT DB.DBA.HTTP_RDF_NET (&#39;sparql load
&quot;http://www.openlinksw.com/dataspace/person/kidehen@openlinksw.com&quot;
into graph &lt;http://www.openlinksw.com/&gt;&#39;);
</pre>
    </div>
      <p>As result should be shown:</p>
<div>
      <pre class="programlisting">
callret
VARCHAR
_______________________________________________________

&lt;?xml version=&quot;1.0&quot; ?&gt;
&lt;rdf:RDF xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot;
xmlns:vcard=&quot;http://www.w3.org/2001/vcard-rdf/3.0#&quot;
xmlns=&quot;http://example.org/book/&quot; xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot;
xmlns:ns=&quot;http://example.org/ns#&quot;&gt;
&lt;rdf:Description&gt;
&lt;callret-0&gt;Load &lt;http://www.openlinksw.com/dataspace/person/kidehen@openlinksw.com&gt;
into graph &lt;http://www.openlinksw.com/&gt; -- done&lt;/callret-0&gt;
&lt;/rdf:Description&gt;
&lt;/rdf:RDF&gt;

1 Rows. -- 1982 msec.
</pre>
    </div>
    <br />
    
      <a name="rdfinsertmethodproxy" />
    <h3>14.8.13. Using the RDF Proxy (Sponger) Service</h3>
    <p>Triples can be inserted also using the Sponger Proxy URI Service. For more information 
    	and examples see <a href="rdfsparql.html#rdfproxyservice">here</a>.</p>
    <br />
<table border="0" width="90%" id="navbarbottom">
    <tr>
        <td align="left" width="33%">
          <a href="rdfviewsenterpr.html" title="Examples of Linked Data Views">Previous</a>
          <br />Examples of Linked Data Views</td>
     <td align="center" width="34%">
          <a href="rdfandsparql.html">Chapter Contents</a>
     </td>
        <td align="right" width="33%">
          <a href="virtuososponger.html" title="RDFizer Middleware (Sponger)">Next</a>
          <br />RDFizer Middleware (Sponger)</td>
    </tr>
    </table>
  </div>
  <div id="footer">
    <div>Copyright© 1999 - 2009 OpenLink Software All rights reserved.</div>
   <div id="validation">
    <a href="http://validator.w3.org/check/referer">
        <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" />
    </a>
    <a href="http://jigsaw.w3.org/css-validator/">
        <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" />
    </a>
   </div>
  </div>
 </body>
</html>