Handling URIs as a Request Parameter in Semantic Web Applications

Over the past few years, in a number of applications, I have used RDF as a data model and used Jena to manage and query data. For new applications, I try to keep the applications RESTful, and the URLs in the application usually have some representation in RDF. For instance:

http://example.com/foo/bar/1/

However, sometimes you need to deploy or call a URI from a servlet in the query parameter:

http://example.com/foo/bar/1/?id=http://example.com/foo/bar/xyz/

URLs become pretty ugly and unfriendly, especially when coding:

http://example.com/foo/bar/1/?id=http%3A%2F%2Fexample.com%2Ffoo%2Fbar%2Fxyz%2F

Are there any best practices in design? Should I create a separate shorter value than the URI in RDF that I can request?

+3
source share
3 answers

Not sure if you can do this altogether. If you relate to another web application, the established standard refers to relative URLs, then this resolves the id argument against the request URL:

http://example.com/foo/bar/1/?id=/foo/bar/xyz/
http://example.com/foo/bar/1/?id=../xyz/

(code as needed)

This helps in the examples given, since the two URLs are in the same domino. Otherwise, I suppose you just need to accept full URLs.

Prefixes are commonly used in the RDF world, of course, but it doesn’t feel very RESTful unless you provide a means to look up mappings.

0
source

, URI q- - , :

http://example.com/foo/bar/1/?id=example:xyz

API , , , , (: rdfs:label skos:notation). , RDF.

+3

-, . answer.semanticweb.com:

, SPARQL, :

RewriteCond %{HTTP_ACCEPT} (text/turtle|application/rdf+xml)
RewriteRule !^/sparql /sparql?query=CONSTRUCT\s{?s\s?p\s?o}\sWHERE\s{?s\s?p\s?o.\s<%{REQUEST_SCHEME}://%{HTTP_HOST}%{REQUEST_URI}%{QUERY_STRING}>\s?p\s?o} [L,R=303]

I think that in general, dereferencing URIs are much preferable to passing URIs as a query string. Depending on your structure, you can even use a URI as the primary key for a domain object (possibly on GRAILS and RAILS).

+3
source

All Articles