|
|
Index
| Recent Threads
| Who's Online
| User List
| Search
| Help
| |
|
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. |
![]() |
openRDF.org Forum » Sesame & Rio: Help » Thread: SPARQL - Filter Namespaces |
|
Total posts in this thread: 5 |
[Add To My Favorites] [Watch this Thread] [Post new Thread] |
| Author |
|
|
Aug 31, 2008 10:38:19 AM
turnguard Regular Joined: Mar 22, 2008 Posts: 34 Status: Offline |
hy there! 1. is there a native sparql [ maybe serql ] way of filtering query out according to a namespace : for example if you have owl and skos is your store and want to only show classes with the skos-namespace [ i can't use contexts to make them look different ] . 2. if not : is there a way i could teach the sparql - engine the arq-extension functions from here http://jena.sourceforge.net/ARQ/library-function.html any help appreciated wkr www.turnguard.com |
||
|
|
Aug 31, 2008 7:37:15 PM
turnguard Regular Joined: Mar 22, 2008 Posts: 34 Status: Offline |
i allready found out myself , very simple ... public class NameSpace implements Function { public String getURI() { return "http://www.turnguard.com/functions#namespace"; } public Value evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { try { URI u = (URI)args[0]; return valueFactory.createURI(u.getNamespace()); } catch (Exception e){ throw new ValueExprEvaluationException(); } } } might not be elegant, but it exactly does what i need |
||
|
|
Aug 31, 2008 7:44:31 PM
turnguard Regular Joined: Mar 22, 2008 Posts: 34 Status: Offline |
so i can use the above class like this PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX tg:<http://www.turnguard.com/functions#> SELECT DISTINCT ?Class WHERE { { ?Class rdf:type <http://www.w3.org/2000/01/rdf-schema#Class> . OPTIONAL { ?Class rdfs:subClassOf <http://www.w3.org/2000/01/rdf-schema#Class> . } } . FILTER(tg:namespace(?Class)=<http://www.w3.org/2004/02/skos/core#>) } |
||
|
|
Sep 1, 2008 8:22:00 AM
arjohn OpenRDF project lead The Netherlands Joined: Jan 23, 2004 Posts: 1289 Status: Offline |
Good that you've found this yourself. Info for any future readers: one can implement the org.openrdf.query.algebra.evaluation.function.Function interface to implement your own functions. After registering the function implementation in the appropriate service description file (/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function) it will be available to Sesame's query engine. Note that SeRQL natively supports the NAMESPACE function, e.g.: SELECT DISTINCT Class ---------------------------------------- Arjohn Kampman, OpenRDF project lead, Aduna |
||
|
|
Sep 1, 2008 8:47:34 AM
turnguard Regular Joined: Mar 22, 2008 Posts: 34 Status: Offline |
or register the new function like so org.openrdf.query.algebra.evaluation.function.FunctionRegistry.getInstance().add(new Namespace()); if you're experiencing any troubles with META-INF and tomcat or so.. Namespace implements Function in this case . see above wkr turnguard |
||
|
| [Show Printable Version of Thread] [Post new Thread] |