简体   繁体   中英

how to retrieve value of an object in RDF when we have subject and properties using jena without sparql?

I want to retrieve my RDF statement's object value and I know how to iterate all of my classes and their respective properties but I don't know how can I access to their objects?

for example :

OntModel rdfModel = ModelFactory.createOntologyModel();
        rdfModel.read("mydata.rdf").read("myontology.rdf");
ExtendedIterator<OntClass> instances =  rdfModel.listClasses();
        while(instances.hasNext())
        {

            OntClass cls = instances.next();
            System.out.println("class name :" + cls.getURI());

            ExtendedIterator<OntProperty> prop = rdfModel.listOntProperties();
            while(prop.hasNext())
            {
                OntProperty ppp = prop.next();
                if (ppp.hasDomain(cls))
                {
                    System.out.println("the properties are :" + ppp.getURI());
                }
            }

now I want to have access to each and every object which have a relation to a property of an interated class.

how should I do that?

You can use OntClass.listProperties(Property). Javadocs are your friend.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM