I am looking for a Java library for parsing SPARQL that would let me extract all the URIs from the queries. I've looked over openRDF (Sesame) a bit, but the API seems a bit over-complicated for such a task, so I'm not sure if I would rather just write my own parser. Any suggestions?

Thank you in advance!

asked 25 Jan '12, 09:23

anca_dumitrache's gravatar image

accept rate: 0%


Have a look at this somewhat similar question and the provided answer on how to do this using Sesame's SPARQL parser: http://answers.semanticweb.com/questions/3187/extracting-s-p-o-tuple-statements-from-sparql-queries

(25 Jan '12, 21:23) Jeen Broekstra ♦ Jeen%20Broekstra's gravatar image

In Oracle, you an just query the model for the URI...

(26 Jan '12, 16:43) Randy DeWool... Randy%20DeWoolfson's gravatar image

I don't know of any library that does just what you say and nothing more. But I imagine you'll probably do well to use Sesame or ARQ to parse the query and then just walk the resulting query tree to identify the URIs. This smells to me like a situation in which dealing with something that is over-complicated is going to be a better (quicker, easier) choice than building your own solution, as tempting as the latter option often is to us engineers.

permanent link

answered 25 Jan '12, 09:27

lee's gravatar image

accept rate: 37%


+1 for using an existing tool. I know with Sesame that you can use just the core RDF model & the SPARQL parser pretty much standalone, you dont need all the Sail, Repository, RIO etc bits, so you can get away with less than the full monty if you just need SPARQL parsing. I suspect that it is the same case with ARQ.

(25 Jan '12, 15:31) mhgrove mhgrove's gravatar image

Whistles …coughs… …regex… feels ashamed.

permanent link

answered 25 Jan '12, 17:24

brinxmat's gravatar image

accept rate: 15%

show me a regex and I'll show you a query on which it fails...

(25 Jan '12, 18:25) Gerrit V Gerrit%20V's gravatar image

depending on whether you need something that always works or just that usually works, this might be a good solution.

(25 Jan '12, 20:43) lee lee's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 25 Jan '12, 09:23

question was seen: 2,161 times

last updated: 26 Jan '12, 16:43