On 07/09/13 00:30, Saud Al-Jaloud wrote:
Hi,

Is there a way with Jena api to pass a SPARQL query that can return the regex 
pattern?

For example:
A query like: "PREFIX  dc:  <http://purl.org/dc/elements/1.1/>
SELECT  ?title
WHERE   { ?x dc:title ?title
           FILTER regex(?title, "^SPARQL")
         }"
Should return "^SPARQL". if there are more than one regex, it should return all 
regex patterns.

I'm already using my version of regex search to extract the pattern, though it 
still misses some patterns. I'd think using Jena is more certain in returning 
the exact pattern.
The finest I could get to is to return the query pattern using 
Query.getQueryPattern(); not any further.

Thanks,
Saud.


Query.getQueryPattern() returns an Element. You can walk that using a ElementVisitor.

As you're working with the internals of the system, you'll probably want to look at the source code. If you look at the classhierarchy (in Eclipse for example) of ElementVisitor, you'll see some examples.

You may find work with the algebra easier.
http://jena.apache.org/documentation/query/algebra.html

and the OpVisitor, of which there are lots of examples in the code.

        Andy

Reply via email to