Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8797827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:56:09+00:00 2026-06-13T23:56:09+00:00

I’ve been using Jena for a while in my research project, however I have

  • 0

I’ve been using Jena for a while in my research project, however I have recently been trying to use SPARQL queries to help my program do some tasks more efficiently.

I tested a set of queries using Twinkle ( http://www.ldodds.com/projects/twinkle/ ) and got the desired results – but when implementing them in Jena additional results were returned.

For example in Twinkle

SELECT ?x WHERE { ?x rdfs:domain ns:Area .  ?x rdfs:range ns:Structure }

returns 1 result in twinkle ( ns:Contains ), whereas when run in my program using Jena it returns another property ( ns:testProperty ) which it should not as the range and domain do not match. I can’t figure out why there is this discrepancy, any pointers would be appreciated.

My Java code is as follows:

Query q = sparqlQueryGetProperties(s, o);

QueryExecution qexec = QueryExecutionFactory.create(q, m);

try {
    Iterator<QuerySolution> rs = qexec.execSelect();

    for (; rs.hasNext();) {
        QuerySolution soln = rs.next();
        if(soln.contains("x")){
            RDFNode r = soln.get("x");

            Resource rss = r.asResource();

            props.add(rss.getLocalName());
        }
    }
} finally {
    qexec.close();
}

Other information:
Sparql v1.0
Jena Core 2.7.4
Jena ARQ 2.9.4

Full query used for testing:

PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>  
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX ns:<http://www.semanticweb.org/ontologies/2012/1/Ontology1328444427428.owl#>   
PREFIX owl: <http://www.w3.org/2002/07/owl#> 

SELECT ?x WHERE { ?x rdfs:domain ns:Area .  ?x rdfs:range ns:Structure }

UPDATE

Unfortunately I am still getting additional resources returned from my test cases in TWINKLE

Here is the exact SPARQL query being run on both Twinkle and in Jena:

PREFIX  rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX  ns:   <http://www.semanticweb.org/ontologies/2012/1/Ontology1328444427428.owl#>
PREFIX  owl:  <http://www.w3.org/2002/07/owl#>
PREFIX  rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT  ?prp ?x
WHERE
  { ns:cathedral  ?prp  ?x .
?x        rdf:type  owl:NamedIndividual .
FILTER ( ?prp != ns:hasShape )
}

Results in TWINKLE:

?prp = ns:within ?x = ns:Campus

Results in JENA:

(?prp -> ?x)
sameAs -> cathedral
disjoin -> cathedral
differentFrom -> Cath_point_4  //This particular relationship seems completely random.
topObjectProperty -> cathedral
within -> Campus

Here is the data I am using (this is a ontology I have developed for testing only):

http://cgi.csc.liv.ac.uk/~roscminni/ontResources/spatialOntCopy.owl

Is there a better tool for testing queries that Twinkle taking into account that Twinkle appears to be out of date?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:56:10+00:00Added an answer on June 13, 2026 at 11:56 pm

    The difference is that in your Jena code you use a OntModel while Twinkle uses only a normal Model

    Internally in Jena a SPARQL query over a Model translates into a number of find() calls on the Model. With an OntModel those find() calls will include inferred triples hence the extra results.

    What additional results you get with an OntModel will depend on what ruleset you chose when you created your model.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
I have thousands of HTML files to process using Groovy/Java and I need to
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.