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

  • SEARCH
  • Home
  • 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 8584705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:50:05+00:00 2026-06-11T21:50:05+00:00

OntModel onto = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_MICRO_RULE_INF, null ); String inputFileName = ./src/test.xml; InputStream in =

  • 0
    OntModel onto = ModelFactory.createOntologyModel(
            OntModelSpec.OWL_MEM_MICRO_RULE_INF, null );

    String inputFileName = "./src/test.xml";    

    InputStream in = FileManager.get().open(inputFileName);
    if (in == null) {
        throw new IllegalArgumentException( "File: " + inputFileName + " not found");
    }

    onto.read(new InputStreamReader(in), "");        

    //ns is the namespace...
    OntClass userClass = onto.getOntClass(ns+"User");

    Individual dada = onto.createIndividual(ns+"Daryl", userClass);

    Property prefBathtub = onto.getProperty(ns+"prefersBathtub");
    Property prefBathtubWt = onto.getProperty(ns+"prefersBathtubWeight");

    dada.addLiteral(prefBathtub, true);
    dada.addLiteral(prefBathtubWt, 0.30);

    OutputStream out = new FileOutputStream("./src/test2.xml");
    onto.write( out, "RDF/XML"); // readable rdf/xml
    out.close();

How do I use OntProperty and/or DatatypeProperty instead of just Property?

By using Property do I get the same amount of expressiveness?

  • 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-11T21:50:06+00:00Added an answer on June 11, 2026 at 9:50 pm

    To get an ObjectProperty object from an ontology model, use OntModel.getObjectProperty(). Likewise for datatype properties, etc. The Ont classes are more expressive in the sense that they contain convenience API for getting, for example, the super-properties of a property, with one method call. However, as the convenience API only accesses the underlying triples in the graph, there is strictly speaking nothing you can do with an ObjectProperty that you can’t do with a Property. It’s just harder work!

    Incidentally, Jena allows you to access other facets of an underlying RDF resource with the .as() method. So:

    Property p = myModel.getProperty( "http://example.com/foo#p" );
    OntProperty op = p.as( OntProperty.class );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

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 simple model public class OneModel { public string Email { get;
I am new to Jena. I want to create a new OntModel and need
I have a problem reading OWL/XML files from Java using Jena. I have no
I can't save any writing update to my RDF/XML OWL file using Protege. Each
I'm trying to use Jena. For creating a new ontology my code is: String
I want to index two different OntModel and execute sparql queries on them. For
I have a Jena ontology model ( OntModel ) which I'm modifying programatically. This
I am trying sparql and the use of entailment. As a example i used
I have created an RDF/OWL file using Protege 4.1 alpha. I also created a

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.