sparql,jena , sparql to retreive the value of a min constraint

sparql to retreive the value of a min constraint


Tag: sparql,jena

How can I retreive a min constraint on a class' attribute using sparql? I have value min 1000 decimal, and I would like to get 1000



Here is the sparql query I used following Artemis' answer

WHERE {?s rdfs:subClassOf ?o.
       ?o owl:minQualifiedCardinality ?min. 
       FILTER(?s = :value) }

And with jena, I use getLiteral("min").getFloat();


SPARQL: How do I List and count each data type in an RDF dataset?

I am trying to count the instances of each datatype in a dataset. It is a simple dataset with only three data types: integer, string and dateTime. I can get the number of datatypes (3) by querying: SELECT (COUNT(DISTINCT datatype(?o)) AS ?dTypeCount) {?s ?p ?o. FILTER (isLiteral(?o)) } GROUP BY...

How to do a count and select variables in Sparql

Is there a way to select variables and get a count of the total variables in one Sparql query ? I want to return ?s and get a count of all the ?s matches I tried variations of the query below but I keep getting errors SELECT (COUNT(*) as ?cnt)...

Get position of item in rdf type sequence with sparql

i have a sequence encoded like this in rdf: _:blanknode <> <>. _:blanknode <> uri:a. _:blanknode <> uri:b. _:blanknode <> uri:c. now i want to have the position of a given uri within this list. is there something like: SELECT ?position WHERE { _:blanknode...

sparql to retreive the value of a min constraint

How can I retreive a min constraint on a class' attribute using sparql? I have value min 1000 decimal, and I would like to get 1000 Thanks...

Counting numbers of DBpedia wikilink and external link using SPARQL

I am currently querying DBPedia for a list of person names by using the SPARQL package in R. And now I am working on counting of different categories for one person, such as the number of wikilink or external_link. But I only know to count all the items together per...

MarkLogic 8 - Node.js Client API - Can I do a SPARQL Query?

As the title says, I want to know if I can do a SPARQL query in the node.js client API or if I need to use the Server Side Javascript API.

RDF SPARQL query multiple types

I am trying to parse a rdf graph using SPARQL. Naturally in a graph my entities can be more than one type at a time. How does a SPARQL query have to look like so that I can check for both types? How my graph looks like: <ns0:TrainArrival rdf:about=""> <ns0:arrivalTime...

SPARQL subquery in DBpedia

I want to filter a resource that is used as "join" in the query. For example, given a DBpedia resource, i need to return the label of resources linked by sameAs property and has "pt" in its URI. I am using the following query: SELECT ?label { <> owl:sameAs ?nomePT....

Simple SPARQL query on dbpedia results doesn't match expectations

I am struggling with the following SPARQL query executed via at DBpedia's SPARQL endpoint: select (count(?abstract) as ?count) where { <> dbpedia-owl:abstract ?abstract . } SPARQL seems pretty simple and when I look at the linked data page, it appears that expected result would be 9. But the actual response...

Does Jena support enforcing OWL constraints during a SPARQL Update query?

I'm trying to figure out if Jena (or any other SPARQL Update server) will enforce ontological constraints. For example, I want to enforce that only entities which have type x are allowed to have property y and the value of the property must have type z. I think this is...

Sparql query not showing results

I have an ontology (dgo.owl) and a simple program ( to query the same ontology. On running the query I do not get any results. After debugging for a long time I thought it would be good to put it in the community. The query script is as: OntModel ontmodque...

multiple users accessing RDF file for read and write

I am using an RDF file to store links (URLs) of online resources that are added by different users about various topics. I am using Jena API to read and write the RDF file, on Apache server. My concern is that multiple users would allowed at the same time to...

sparql insert with where clause

How to insert insert query with "where" condition in 4store sparql As far as I have searched I got to know that we have to use curl command for the same.I tried using this Process p = Runtime.getRuntime().exec(new String[]{"bash","-c","curl -i -d 'update=INSERT+DATA+{+?subject2+<>+?subject3+.+}+WHERE+{+?subject2+<http://localhost:2020/vocab/Schema_feature>+\""+first[0]+"\"+.+?subject3+<http://localhost:2020/vocab/Schema_feature>+\""+first[1]+"\"+.+}' http://localhost:8000/update/"});...

How to get all nouns in a certain language from Wiktionary using SPARQL

I'm trying to query Wiktionary with SPARQL to get all the terms that are nouns of a certain language (for example German) and as output: the string of the noun the grammatical gender (genus): male, female, neutral I am using the SPARQL-Endpoint: and I found an example but I...

Virtuoso 37000 Error SP030

why is showing this error, i see in the sparql query is correct, i don't see any mistake in prefix. PREFIX rdfs:<> PREFIX type: <> PREFIX prop: <> SELECT ?country_name ?population WHERE { ?country rdf:type dbpedia-owl:Country; rdfs:label ?country_name ; prop:populationEstimate ?population . FILTER (?population > 2334456) . FILTER ( lang(?country_name)...

Why does STRAFTER return blank data in json binding in angular?

I am using angular to bind the results of a SPARQL query. It works nicely until I attempt to bind data returned from queries using the SPARQL "STRAFTER" or "REPLACE" functions (code below) which returns blank data in $scope. But the same query works fine if I run it directly...

What is the difference between a temporal and a non-temporal query

I have read some resources that talk about temporal and non-temporal queries, specifically with SPARQL. What is the difference between these two kinds of queries?

SPARQL: selecting people by country

toI am trying to select all people born in some country (e.g. Portugal) from DBPedia. I could use such request SELECT DISTINCT ?person WHERE { ?person dbpedia-owl:birthPlace dbpedia:Portugal. } But the problem is that not all people has dbpedia:Portugal as birthPlace. About 30% of people has just a town name...

SPARQL: Unresolved prefixed name: dbpprop:author

I'm running this query. It works fine on DBpedia (, but it doesn't work in my Java code: PREFIX res: <> PREFIX dbpedia-owl: <> SELECT ?book WHERE { ?book a dbpedia-owl:Book . ?book dbpprop:author ?author . ?author dbpprop:name ?name FILTER regex(?name, "Agatha Christie", "i") } Infact, as stated by the...

Compare average - SPARQL

There is a dataset of users ranking movies. Need to find the users with similar taste to user1. Similar taste defined as follows: consider the average rank for genre from user1 as avgr1 and for the same genre from user2 as avgr2, then user1 and user2 have similar taste is...

Sparql query to get all classes that are subclass of a “property class”

I need to "annotate" some classes by adding a property to them. I need to do that in order to let the view layer of my application extract the correct classes. What I have done is: create an object property called uiProperty and edit these classes to make them subclass...

How to use the ASK WHERE statement with multiple conditions (sparql)

I want to check if an entity has one of the types listed below. If it does then the query must return true. PREFIX basekb:<> basekb:music.release_track basekb:book.written_work basekb:music.release basekb:music.album basekb:tv.tv_series.episode basekb:music.composition basekb:music.recording basekb:fictional_universe.fictional_character Entity m.0109yb6 has the following types. The sparql query should return true

select the negative of a SPARQL query

Is possible to select the "negative" of a sparql query? For instance, consider the following RDF data, query and desired result: knowledge base: @prefix gr:<>. @prefix rdfs:<>. :prod_A :hasProp :propA. :prod_B :hasProp :propB. :propB rdfs:label "Hello". :prod_C :hasProp :propC. :prod_D :hasProp :propD. Imaginary Query: PREFIX gr:<> SELECT ?prod WHERE {...

Storing separately individuals and ontology in sesame store

I have an ontology that I imported in a sesame repository. I want to add individuals for the classes that are defined in my ontology. Is it possible to add the individuals into another repository and not in the one that has stored the ontology? If this is possible how...

How to retrieve person names from DBPedia in different language versions?

I am currently querying DBPedia for a list of person names by using the SPARQL package in R. I noticed that when I use SPARQL query for English DBPedia like this: endpoint = "" query= "SELECT *{ dbpedia:Veit_Dietrich ?p ?o }" qd=SPARQL(endpoint,query) df=qd$results Everything is fine, but if I want...

setting soft limit for 4store client

While running the sparql queries I get the warning # hit complexity limit 20 times, increasing soft limit may give more results and this is not dependent to any particular query but for all.I wanted to know how can I increase the soft limit if I am not using the...

How to get a single name for multiple name properties in DBPedia with SPARQL?

I need to get persons' names from DBPedia, but the problem is that not every person has the dbpprop:fullname property, sometimes it only has the dbpprop:name or the rdfs:label property. To clarify: I want to query for the name with a preference for the first property, if that doesn't exist...

Persisting data in Jena TDB triple store

I am using Jena TDB to persist RDF data. Before this I searched how to persist data in TDB and I came through the question at this link. Answer provided by Ryan clearly mentions the difference between various concepts, and one of the point I got about datasets is: "A...

SPARQL Group-Concat not working

I've got an RDF graph element looking like this using Android & Jena: <ns0:CalendarItem rdf:about=""> <ns0:attendee rdf:resource="" /> <ns0:attendee rdf:resource="" /> <ns0:attendee...

Is it possible to Filter Graphs in a way that they at most contain requested Data?

Let me start with an example query to explain my problem: SELECT ?g ?s ?p ?o WHERE { {GRAPH ?g { ?s ?p ?o. OPTIONAL{ ?s ab:temperature ?temperature.} FILTER (?temperature = 20) FILTER NOT EXISTS {?s ab:person ?person} } } } This query gives me all graphs (in this case...

Unexpected End of Stream while trying to tokenise sparql query

i have this my rdf file and i try to get all triples from specific namespace 'ns1' <?xml version="1.0"?> <rdf:RDF xmlns:rdf="" xmlns:dc="" xmlns:ns1="" xmlns:property="" xmlns:info=""> <rdf:Description rdf:about=""> <ns1:be rdf:resource=""/>...

Can SPARQL handle blank results for specific cells?

I am writing a SPARQL query and cant figure out how to allow blank results for specific columns. My current request is: select * where { ?game a dbpedia-owl:Game ; dbpprop:name ?name ; dbpedia-owl:publisher ?publisher . } Some Games have an owl for publisher while others do not. The above...

MarkLogic 8 - SPARQL - Follow synonym chain

Let's say I have lots of ontologies with synonyms. <term> <word>cat</word> <synonyms> <synonym>feline</synonym> </synonyms> </term> <term> <word>feline></word> <synonyms> <synonym>kitty</synonym> <synonyms> </term> How can I write a SPARQL query such that I can give it the word cat and it will give me all the synonyms of cat as well as...

URLError with SPARQLWrapper at sparql.query().convert()

I try a small python script to test my SPARQL request. However, just the next simple code doesn't work. from SPARQLWrapper import SPARQLWrapper, JSON import rdflib #connect to the sparql point sparql = SPARQLWrapper("http://localhost:3030/sparql") #SPARQL request sparql.setQuery(""" PREFIX rdf: <> PREFIX rdfs: <> PREFIX owl: <> PREFIX xsd: <> PREFIX...

Loading owl file with Jena

I load several OWL files (RDF/XML serialization) with Jena as OntModel. For some files I get an error when reading them with Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/HttpMessage. I have org.apache.httpcore-sources.jar in the classpath. The file which currently poses problem is: I saved it with Protege as RDF/XML,...

Optimize SPARQL Query

I have query that finds similar tastes in movies. Such that the absolute value of difference between average rankings of users over same genre is less that 1: SELECT ?p ?p1 ?genre WHERE{ ?p movies:hasRated ?rate. ?p1 foaf:knows ?p. ?rate movies:ratedMovie ?mov. ?rate movies:hasRating ?rating. ?mov movies:hasGenre ?genre. ?p1 movies:hasRated...

Query multiple models within same Dataset in TDB Jena

I have an ontology (say dgo.owl) and another file containing individuals for same ontology stored in rdf format. I have stored both (ontology and instances/individual file) files in TDB under different named models (say dgo_ont and homedata). Now, I want to fire different SPARQL queries on a combination of these...

How can I retrieve a list of specific person names from DBPedia by using SPARQL query in R

I am currently using the SPARQL package in R to query DBPedia and get the information for a list of specific person names. But I only know how to query one person or the "person category", such as query= "SELECT *{ dbpedia:Veit_Dietrich ?p ?o }" qd=SPARQL(endpoint,query) df=qd$results Is there anyway...

how to read SPARQL query and pass via $http.get

I am trying to get some data from land registry API ( and it uses SPARQL query. I am new to sparql queries and not sure what to pass in my param.query object and how to pass prefixes required. //myCode var req = { method: 'GET', url: '', headers: {...

Consequence of restrictions in ontology on SPARQL end results

I am concerned about two classes (SensingDevice and Property) of my ontology (dgo.owl) as shown in the below figure. These two classes are connected by observes property: and the related ontology portion is as: <owl:Class rdf:about=""> <rdfs:subClassOf rdf:resource=""/> <rdfs:subClassOf> <owl:Restriction> <owl:onProperty rdf:resource=""/>...

querying RDFs using SPARQL query

Assuming we have a dataset including the following 3 RDF triples. I want to retrieve all these three triples using sparql query. predicate1 predicate1 predicate1 Here is the query I wrote but I know it is not right: prefix pred:<> select distinct * where...

Ontologies, OWL, Sparql: Modelling that “something is not there” and performance considerations

we want to model that "something is not there" as opposed to missing information, e.g. an explicit statement that "a patient did not get chemotherapy" or that "a patient does not have dyspnea" is different from missing information about whether a patient has dyspnea. We thought about several approaches, e.g....

How to add dot '.' in the name of individuals in Sparql?

Is it possible to have . (dot) in the name of the individuals? Something like this? SELECT ?tableName ?fieldName WHERE { ?fieldName hrdata:relatedField hrdata:ps_ti0002.EMPLID. } The dot in ps_ti0002.EMPLID is problematic....

Filter SELECT output by string in Spaql

I have a Sparql query like this : PREFIX rdf: <> PREFIX owl: <> PREFIX rdfs: <> PREFIX xsd: <> PREFIX hrdata:<> SELECT ?tableName2 ?fieldName ?primaryKey1 ?primaryKey2 ?tableName1 WHERE { ?tableName1 hrdata:hasField hrdata:EFFDT. ?fieldName hrdata:relatedField hrdata:EFFDT. ?tableName2 hrdata:hasField ?fieldName....

Count resources having a property of a certain type in SPARQL

I have data in a triple store and would like to compute the following: how many resources 'x' have the object property 'op' with at least 2 different resources 'r' of similar type 'R' as values? here is a example of such data in turtle syntax: PREFIX ex: <> ex:doc1...