Can anyone help me understand this different of output. I listing all the subject in the RDF Graph then print their details. After what i list all object of the graph and if they are a ressource convert them in the ressource they are and print

However, i get totaly different answer as you can see below



static final String inputFileName = "data/promise.rdf";
        
        public static void main(String[] args) {
                
                // create an empty model
        Model model = ModelFactory.createDefaultModel();

        // use the FileManager to find the input file
        InputStream in = FileManager.get().open(inputFileName);
        if (in == null) {
throw new IllegalArgumentException( "File: " + inputFileName + " not found");
        }

        // read the RDF/XML file
        model.read(new InputStreamReader(in), "");

        ResIterator it      = model.listSubjects();
        NodeIterator nodit  = model.listObjects();
        Resource res        = null;
        StmtIterator propIt = null;


        while (it.hasNext()) {
                
                res = it.nextResource();
                
                System.out.println("res:" + res.toString());
                
                propIt = res.listProperties();
                
                while (propIt.hasNext())
System.out.println("property: " + propIt.nextStatement().getPredicate().getLocalName());

        }

System .out .println ("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Objects>>>>>>>>>>>>>>>>>>>>>>>\n");
        res    = null;
        propIt = null;

        while (nodit.hasNext()) {
                RDFNode nod = nodit.nextNode();
                
System.out.println("nod:" + nod.toString() + " : " + nod.isResource());

                        if (nod.isResource()) {
                                res = nod.asResource();
                                
System.out.println("res:" + res.toString() + " : " + res.getLocalName());
                                
                                //propIt = res.listProperties();
                                
                        }
        }
        
                
}


res:http://www.people.lu.unisi.ch/fornaran/example/promise#JohnAction1
property: hasAmount
property: hasRecipient
property: hasDuration
property: hasActor
property: type
res:http://www.people.lu.unisi.ch/fornaran/example/promise#book1
property: type
res:http://www.people.lu.unisi.ch/fornaran/example/promise#MaryAction1
property: hasObject
property: hasRecipient
property: hasActor
property: type

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Objects>>>>>>>>>>>>>>>>>>>>>>>

nod:http://www.people.lu.unisi.ch/fornaran/schemas/app-rdf0#Pay : true
res:http://www.people.lu.unisi.ch/fornaran/schemas/app-rdf0#Pay : Pay
nod:http://www.people.lu.unisi.ch/fornaran/schemas/app-rdf0#Deliver : true res:http://www.people.lu.unisi.ch/fornaran/schemas/app-rdf0#Deliver : Deliver
nod:Mary : false
nod:2 : false
nod:http://www.people.lu.unisi.ch/fornaran/example/promise#book1 : true
res:http://www.people.lu.unisi.ch/fornaran/example/promise#book1 : book1
nod:John : false
nod:http://www.people.lu.unisi.ch/fornaran/schemas/app-rdf0#book : true
res:http://www.people.lu.unisi.ch/fornaran/schemas/app-rdf0#book : book
nod:5 : false

Reply via email to