[rdfweb-dev] [jena-dev] novice Jena foaf parsing question

Dan Brickley danbri at w3.org
Mon Jul 7 22:50:14 UTC 2003


Could someone with some Jena-knowhow perhaps offer some help here? If so 
we can slap it in the wiki and link from FAQ at same time... --danbri
(still in catchup mode...)

----- Forwarded message from James Nachlin <jnachlin at nachlin.com> -----

From: James Nachlin <jnachlin at nachlin.com>
Date: Mon, 7 Jul 2003 17:39:03 -0400 (EDT)
To: jena-dev at yahoogroups.com
Subject: [jena-dev] novice Jena foaf parsing question
Message-ID: <Pine.LNX.4.44.0307071723560.19906-100000 at www.brettsinger.com>
Reply-To: jena-dev at yahoogroups.com

Hi,

I'm trying to parse FOAF graphs using jena, and getting hung up
on what seems like it should be easy.  I have basic code to
create a model and get a list of friends:

import com.hp.hpl.jena.mem.*;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.vocabulary.*;
//created from the foaf schema using the schemagen tool:
import foaf.FOAF;

public class friends {
    public static void main(String[] arrrgh){
        String foafURL = "http://www.nachlin.com/foaf.rdf";
        Model model = new ModelMem();
        model.read(foafURL);
        Property knows = model.getProperty(FOAF.getURI(), "knows");
        Property nID = model.getProperty(RDF.getURI(), "nodeID");
        NodeIterator niter = model.listObjectsOfProperty(knows);
        while(niter.hasNext()){
            RDFNode node = niter.nextNode();
            //just to prove something's happening
            System.out.println("friend> " + node.toString());
        }
    }
}


That's great, but the next step is to access each one of these
friends and get information from that part of the graph.  Jena
is seeing these "friends" in the graph as rdf:Descriptions, like
so:

<rdf:Description rdf:nodeID="A1">
    <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person"/>
    <foaf:name>Lucas Gonze</foaf:name>
    <foaf:mbox_sha1sum>a5bac82a92eadb58f027754cb2d64231602d218c</foaf:mbox_sha1sum>
    <rdfs:seeAlso rdf:resource="http://www.gonze.com/foaf.rdf"/>
</rdf:Description>

I haven't been able to get this simple task accomplished, trying
every approach I can think of and pouring over the tutorials and
docs.  I would like, for instance, to be able to just print the
value of each foaf:name (and more beyone that, of course)

Sorry to be so dense.  Thanks for your help.

Jim Nachlin


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Save on Coral Calcium. Get Better Health and
Stronger Bones. Seen on TV
http://www.challengerone.com/t/l.asp?cid-2805&lp=calcium2.asp
http://us.click.yahoo.com/9gf46B/EfUGAA/ySSFAA/NhFolB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
jena-dev-unsubscribe at yahoogroups.com

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 


----- End forwarded message -----



More information about the foaf-dev mailing list