openRDF.org Welcome Guest   | Login   
  Search  
  Index  | Recent Threads  | Who's Online  | User List  | Search  | Help  | RSS feeds

Forum closing down
This forum will be closing down due to extensive spamming activities. As a first step, registration of new members has been disabled. Existing members will be able to use the forum for now, but please consider using the sesame-general mailing list instead.


Quick Go »
Thread Status: Normal
Total posts in this thread: 16
Posts: 16   Pages: 2   [ 1 2 | Next Page ]
[Add To My Favorites] [Watch this Thread] [Post new Thread]
Author
Previous Thread This topic has been viewed 3087 times and has 15 replies Next Thread
Aug 29, 2007 3:44:44 AM

hendlerman
Regular
Member's Avatar


Joined: Sep 14, 2004
Posts: 36
Status: Offline
HTTP POST for INSERT, DELETE, UPDATE Reply to this Post
Reply with Quote

Hi All,

I am running Sesame 2.0 beta5 and have built a PHP class to connect to it using the Zend Framework for PHP (simple HTTP client/JSON parser). Querying is working great.

I have not been able to figure out how to add/update/ or delete statements from the documentation. I see onthis page, which is still under development, that there is under 8.6.1.x a number of operations available at the path of
/repositories/[repository]/statements
:


  • [TRANSACTION DATA]
  • [TURTLE ENCODED RDF DATA]
  • [RDF/XML ENCODED RDF DATA]


It appears with the above that I must define the header.
Are there any links which might provide further documentation as to what the above DATA types can look like (especially the TRANSACTION data)?

Sorry if I've missed something in the manual.
Thanks.
Show Printable Version of Post        Hidden to Guest    http://semanticsearch.org [Link] Report threatening or abusive post: please login first  Go to top 
Aug 29, 2007 10:47:48 AM

arjohn
OpenRDF project lead
Member's Avatar

The Netherlands
Joined: Jan 23, 2004
Posts: 1289
Status: Offline
Re: HTTP POST for INSERT, DELETE, UPDATE Reply to this Post
Reply with Quote

Turtle and RDF/XML are RDF formats. You can simply PUT or POST data in one of the supported RDF formats to the above URL as-is, which will cause the data to be added to the repository. An overview of the implemented RDF formats and references to their specifications is available in section 8.11 "Content types" of the user guide. Note that you do have to specify the appropriate MIME type for the used data format in the Content-Type header, as per the HTTP spec.

The "transaction data format" is a Sesame-specific format for encoding transactions (which can include removal operations). This is an XML-based format. Unfortunately, the format isn't really documented yet. You may be able to extract it from the source code though, which is available here. I'll give you an example transaction document to get you up to speed:
<?xml version="1.0"?>
<transaction>
<clear>
<contexts>
<uri>http://www.example.org/</uri>
</contexts>
</clear>
<add>
<bnode>abcd</bnode> <!-- subject -->
<uri>http://www.w3.org/2000/01/rdf-schema#label</uri> <!-- predicate -->
<literal xml:lang="en">Bladibla</literal> <!-- object -->
<contexts>
<uri>http://www.example.org/</uri>
</contexts>
</add>
</transaction>

Hope this helps.
----------------------------------------
Arjohn Kampman, OpenRDF project lead, Aduna
Show Printable Version of Post        Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Aug 29, 2007 11:37:07 AM

hendlerman
Regular
Member's Avatar


Joined: Sep 14, 2004
Posts: 36
Status: Offline
Re: HTTP POST for INSERT, DELETE, UPDATE Reply to this Post
Reply with Quote

Perfect. I'll follow up here with how it goes, and link to the source code for the connector class.

Thanks!
Show Printable Version of Post        Hidden to Guest    http://semanticsearch.org [Link] Report threatening or abusive post: please login first  Go to top 
Aug 29, 2007 4:06:58 PM

hendlerman
Regular
Member's Avatar


Joined: Sep 14, 2004
Posts: 36
Status: Offline
Re: HTTP POST for INSERT, DELETE, UPDATE Reply to this Post
Reply with Quote

I've got the 'add' transaction working with a POST, but not the 'clear'.
In some blocks I only have a subject or predicate with a 'clear', assuming that leaving them blank makes them a wildcard. Is this the correct way to do a conditional clear?

<?xml version="1.0"?>
<transaction>
<clear>
<uri>http://semanticsearch.example.com/#testSubject2</uri> <!-- subject -->
<contexts>
<uri>http://semanticsearch.example.com/</uri>
</contexts>
</clear>
</transaction>


or a clear and add (an update?)
<?xml version="1.0"?>
<transaction>
<clear>
<uri>http://semanticsearch.example.com/#testPredicate</uri> <!-- predicate -->
<contexts>
<uri>http://semanticsearch.example.com/</uri>
</contexts>
</clear>
<add>
<uri>http://semanticsearch.example.com/#testSubject</uri> <!-- subject -->
<uri>http://semanticsearch.example.com/#testPredicate</uri> <!-- predicate -->
<uri>http://semanticsearch.example.com/#testObjectUPDATED</uri> <!-- object -->
<contexts>
<uri>http://semanticsearch.example.com/</uri>
</contexts>
</add>
</transaction>



I'm guessing for wildcard I need a bnode, or something, to make sure the parser knows which is the subject/predicate/object?

Also, at the moment, querying is still very fast, but the adds and clears takes 10 seconds via the HTTP stuff (using a memory store).
Show Printable Version of Post        Hidden to Guest    http://semanticsearch.org [Link] Report threatening or abusive post: please login first  Go to top 
Aug 30, 2007 9:59:40 AM

arjohn
OpenRDF project lead
Member's Avatar

The Netherlands
Joined: Jan 23, 2004
Posts: 1289
Status: Offline
Re: HTTP POST for INSERT, DELETE, UPDATE Reply to this Post
Reply with Quote

 
I've got the 'add' transaction working with a POST, but not the 'clear'.
In some blocks I only have a subject or predicate with a 'clear', assuming that leaving them blank makes them a wildcard. Is this the correct way to do a conditional clear?

<?xml version="1.0"?>
<transaction>
<clear>
<uri>http://semanticsearch.example.com/#testSubject2</uri> <!-- subject -->
<contexts>
<uri>http://semanticsearch.example.com/</uri>
</contexts>
</clear>
</transaction>

No, this is not correct. The XML-tags have been named after the operations in the Repository API, the clear-operation only operates on contexts. To remove specific statements, you need to use the remove-operation with <null/> for wildcards, e.g.:
<?xml version="1.0"?>
<transaction>
<remove>
<uri>http://semanticsearch.example.com/#testSubject2</uri> <!-- subject -->
<null/> <!-- predicate -->
<null/> <!-- object -->
<contexts>
<uri>http://semanticsearch.example.com/</uri>
</contexts>
</remove>
</transaction>

 
I'm guessing for wildcard I need a bnode, or something, to make sure the parser knows which is the subject/predicate/object?

Wildcard are indicated by <null/>, <bnode>bla</bnode> identifies a specific bnode.
 
Also, at the moment, querying is still very fast, but the adds and clears takes 10 seconds via the HTTP stuff (using a memory store).

Hmm, that's pretty bad. What the size of the repository? Does it use inferencing?
----------------------------------------
Arjohn Kampman, OpenRDF project lead, Aduna
Show Printable Version of Post        Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Aug 30, 2007 10:43:25 AM

hendlerman
Regular
Member's Avatar


Joined: Sep 14, 2004
Posts: 36
Status: Offline
Re: HTTP POST for INSERT, DELETE, UPDATE Reply to this Post
Reply with Quote

Perfect
<remove>
and
<null/>
did the trick and deleting and updating are working as expected.

 
 
Also, at the moment, querying is still very fast, but the adds and clears takes 10 seconds via the HTTP stuff (using a memory store).

Hmm, that's pretty bad. What the size of the repository? Does it use inferencing?

I've only seen that option for queries, but not for updating - if it is off by default, I am not doing inferencing. The size of the test store is nearly 0, it's an empty store I run some tests on. It may be the PHP code, I do 5 requests in a row that run sequentially (not concurrently).

I'll let you know what I find out. Is there anything I should look for in the configuration of Sesame?
Show Printable Version of Post        Hidden to Guest    http://semanticsearch.org [Link] Report threatening or abusive post: please login first  Go to top 
Aug 30, 2007 11:33:19 AM

arjohn
OpenRDF project lead
Member's Avatar

The Netherlands
Joined: Jan 23, 2004
Posts: 1289
Status: Offline
Re: HTTP POST for INSERT, DELETE, UPDATE Reply to this Post
Reply with Quote

Whether inferencing is enabled or not depends on the repository configuration. The query request parameter simply states whether inferred statements should be considered in the evaluation. So what my question basically comes down to is: did you create an inferencing repository ('memory-rdfs' template in the console), or did you create a non-inferencing repository ('memory' template in console).
----------------------------------------
Arjohn Kampman, OpenRDF project lead, Aduna
Show Printable Version of Post        Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Aug 30, 2007 1:48:05 PM

hendlerman
Regular
Member's Avatar


Joined: Sep 14, 2004
Posts: 36
Status: Offline
Re: HTTP POST for INSERT, DELETE, UPDATE Reply to this Post
Reply with Quote

 
Whether inferencing is enabled or not depends on the repository configuration. The query request parameter simply states whether inferred statements should be considered in the evaluation. So what my question basically comes down to is: did you create an inferencing repository ('memory-rdfs' template in the console), or did you create a non-inferencing repository ('memory' template in console).

It was the "memory" template.
Show Printable Version of Post        Hidden to Guest    http://semanticsearch.org [Link] Report threatening or abusive post: please login first  Go to top 
Aug 30, 2007 6:42:37 PM

hendlerman
Regular
Member's Avatar


Joined: Sep 14, 2004
Posts: 36
Status: Offline
Re: HTTP POST for INSERT, DELETE, UPDATE Reply to this Post
Reply with Quote

I tested with "native" template as well and it the same speed issues appeared. Actually around 20 seconds per submit.

I noticed that the return is "HTTP/1.1 204 NO CONTENT". I thought that maybe this was causing the PHP HTTP client do something wrong. I've found a bug in Zend's code with handling 204, since they try to read an empty buffer on the socket!

So everything is good here! Look for a post with the code I've been using and a patch for Zend ;).

Thanks for all the help!
Show Printable Version of Post        Hidden to Guest    http://semanticsearch.org [Link] Report threatening or abusive post: please login first  Go to top 
Aug 30, 2007 7:02:16 PM

hendlerman
Regular
Member's Avatar


Joined: Sep 14, 2004
Posts: 36
Status: Offline
Re: HTTP POST for INSERT, DELETE, UPDATE Reply to this Post
Reply with Quote

attached is a patch for the Zend Framework.
----------------------------------------
Attachment ZEND-FRAMEWORK-1.01-SOCKET-PATCH.txt (905 bytes) (Download Count: 361) (A simple patch to the socket/httpclient in the Zend framework that was causing the speed issues.)

Show Printable Version of Post        Hidden to Guest    http://semanticsearch.org [Link] Report threatening or abusive post: please login first  Go to top 
Posts: 16   Pages: 2   [ 1 2 | Next Page ]
[Show Printable Version of Thread] [Post new Thread]