2

i have an RDF File with FOAF vocabulary, and i want to display the file with a jsp. What do i need for this??

OK i just got the message from the tutor that i must use JSP and Jena...i can create the file and read with servjet&jena, but now is the problem how to show the rdf file with jsp...for example if i have a picture for a person how can i show this with jsp...i can sparql to find all the friends, but dont know how to show them with jsp...for example how to print the result of ResultSetFormatter.out(System.out.r,q) with jsp?? thx in advance for all the tipps

user576914
  • 189
  • 4
  • 22

3 Answers3

2

If you want just a readable version of the RDF/XML file one way is to apply and XSLT template.

You could do more sophisticated stuff if you load it with a library like Jena that provides different ways of querying and traversing the data.

In case your file is big and contains thousands or millions of triples then you might want to load it in a triple store like Virtuoso or 4store and use SPARQL to query your data.

If you explain a bit more your scenario we might be able to help better.

Manuel Salvadores
  • 15,398
  • 4
  • 33
  • 56
  • 1
    the scenario is as follows: i create the file with jena, but i want to display the information with html code...so when someone clicks on my profile, all the infos that describe me inside the rdf file should be displayed with html code...i use html inside jsp becouse i need to use java too(jena).. thx in advance – user576914 Jan 15 '11 at 19:46
  • It seems that XSLT could be one option. Another option is to use Jena also to read the RDF, traverse the triples and show them in HTML. Look at the Jena API you also have methods to query RDF Models. – Manuel Salvadores Jan 15 '11 at 19:52
  • Thx for your suggestion..what would you use..xslt or jena?? thx – user576914 Jan 15 '11 at 19:54
  • I think for your case Jena is a an overkill. Go for XSLT. As Pierre commented in his answer have a look at his profile which I think will give you all what you need to do it. Specially the top part of the XML where it says ... – Manuel Salvadores Jan 15 '11 at 20:25
  • @user576914 at the corner of the page you suggest http://xml.mfd-consult.dk/foaf/explorer/?foaf=http%3A%2F%2Fwww.robertprice.co.uk%2Ffoaf.rdf there's the XSLT you could use http://xml.mfd-consult.dk/foaf/explorer/explorer.xsl – Manuel Salvadores Jan 15 '11 at 20:32
1

is it a static file ? what can of display do you want ? just echoing the XML ? you don't need the JSP. Just place your RDF file in a public place of your deployment folder. e.g: Deploying just HTML, CSS webpage to Tomcat

'''EDIT''': regarding your comment, I would associate a XSLT stylesheet to the RDF/XML file instead of processing the RDF via tomcat. See the source of my FOAF page: http://lindenb.github.com/foaf.xml

Community
  • 1
  • 1
Pierre
  • 31,741
  • 29
  • 101
  • 180
  • 1
    HI, i want smthg like this: http://xml.mfd-consult.dk/foaf/explorer/?foaf=http%3A%2F%2Fwww.robertprice.co.uk%2Ffoaf.rdf and not http://heddley.com/edd/foaf.rdf thx in advance ... i want to display with html tag – user576914 Jan 15 '11 at 19:49
  • i like the idea with XSLT...so i can edit the file with jena and use XSLT to show it...is this a good option?? thx – user576914 Jan 20 '11 at 18:49
0

Do you really want to just visualize the RDF, or do you want to attach semantics to some other presentation? If the later, you want microformats.

In any case, RDF/XML is a pita, it's unlikely that you'll enjoy using XSLT to map it to any particular visual presentation. Better to write Java code using Jena, and just use JSP to render that as the HTML of your choice. Or turn it into JSON and render a graph with TheJIT.

bmargulies
  • 91,317
  • 38
  • 166
  • 290
  • I totally disagree. There are tons of XSLT templates out there for FOAF. He could easily reuse one, for instance the one from @pierre, and tune it a bit wouldn't be too complicate. Jena and JSP for this simple task is definitely an overkill. – Manuel Salvadores Jan 15 '11 at 20:28
  • Well, then, you should downvote my answer. I know something about rendering RDF in general, you know more about FOAF in particular. – bmargulies Jan 15 '11 at 23:07