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 8795511
In Process

The Archive Base Latest Questions

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

I created an Ontology model in Java using the Apache Jena library, and I

  • 0

I created an Ontology model in Java using the Apache Jena library, and I entered pizza ontology.
I am trying to make a sparql query but the table print is blank, although normaly there are answers to my query.
Am I doing something wrong…?
Here is the code:

OntModel model = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_MICRO_RULE_INF);
String inputFileName="pizza.owl";
InputStream in = FileManager.get().open( inputFileName );
if (in == null) {
    throw new IllegalArgumentException(
         "File: " + inputFileName + " not found");
}
model.read(in, null);

String queryString =
        "prefix pizza: <www.co-ode.org/ontologies/pizza/pizza.owl#Pizza> "+        
        "prefix rdfs: <" + RDFS.getURI() + "> "           +
        "prefix owl: <" + OWL.getURI() + "> "             +
        "select ?pizza where {?pizza a owl:Class ; "      +
        "rdfs:subClassOf ?restriction. "                  +
        "?restriction owl:onProperty pizza:hasTopping ;"  +
        "owl:someValuesFrom pizza:PeperoniSausageTopping" +
        "}";
Query query = QueryFactory.create(queryString);
QueryExecution qe = QueryExecutionFactory.create(query, model);
com.hp.hpl.jena.query.ResultSet results =  qe.execSelect();

ResultSetFormatter.out(System.out, results, query);
qe.close();
  • 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:24:09+00:00Added an answer on June 13, 2026 at 11:24 pm

    Your prefix declaration is wrong. You have accidentally included the name of the Pizza class, and also left off the http protocol prefix. Corrected, it should be:

    "prefix pizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#> "+
    

    The way prefixes work in RDF and SPARQL is that you replace the prefix: with whatever the prefix is defined to be, and the resulting string must exactly match the URI of the resource you are trying to match. It must be an exact match – even differences in the case of letters is significant.

    By the way, you can also simplify loading the ontology via the FileManager:

    OntModel model = ModelFactory.createOntologyModel( 
                                      OntModelSpec.OWL_MEM_MICRO_RULE_INF);
    FileManager.get().readModel( model, "pizza.owl" );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this java code that, using apache jena api, queries the pizza ontology
I would like to visualize an Ontology model created through Jena in Java. Is
I'm using servlet for manipulating ontology. I got the result of my SPARQL query
I'm trying to query an xml file using the following xslt: <xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform
I want to create a simple application using Jena and SPARQL, that inserts, deletes,
I can retrieve individuals from my ontology using following query: SELECT ?indiv WHERE {
I've created an ontology using Protege and would now like to add individuals with
I'm annotating sensor observations using JENA, RDF and the W3C SSNXG's sensor ontology. I've
package tutorial; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import com.hp.hpl.jena.ontology.OntModel;
I have a Jena ontology model ( OntModel ) which I'm modifying programatically. This

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.