Jena A Java API for RDF - PowerPoint PPT Presentation

Loading...

PPT – Jena A Java API for RDF PowerPoint presentation | free to download - id: 347fe-ZjNkY



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Jena A Java API for RDF

Description:

hotmail _at_yahoo. Tut:name. Tut:email. Tut:email. Jena. A Java API for RDF ... Can parse, create, and search RDF models. Easy to use. Install and Run Jena ... – PowerPoint PPT presentation

Number of Views:540
Avg rating:5.0/5.0
Slides: 20
Provided by: xian4
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Jena A Java API for RDF


1
Jena --- A Java API for RDF
  • Jing deng
  • CSCI 7818 Web Technologies
  • Computer Science Department
  • University of Colorado at Boulder
  • Wednesday, October 31, 2001

2
Outline
  • Introduction RDF and Jena
  • Install and Run Jena
  • Jena package and Interface
  • Jena API examples
  • References

3
RDF
  • Resource Description Framework
  • represents information on Web with
    machine-understandable syntax and semantics
  • Framework Subject has the predicate whose value
    is object
  • Resource (Subject)
  • Property (Predicate)
  • Literal (Object)

4
RDF (Cont.)
Tutorial
DCcreator
DCtitle
  • DCdate

Oct 31 2001
Introduction
5
Jena
  • A Java API for RDF
  • Developed by Brian McBride of HP
  • Derived from SiRPAC API
  • Can parse, create, and search RDF models
  • Easy to use

6
Install and Run Jena
  • Get package from http//www.hpl.hp.co.uk/people/bw
    m/rdf/jena/download.htm
  • Unzip it
  • Setup environments (CLASSPATH)
  • Test tutorial programs
  • http//www.bmcb.btinternet.co.uk/2001/rdf/jenatuto
    rial/
  • Online documentation
  • http//www.hpl.hp.co.uk/people/bwm/rdf/jena/javado
    c/index.html

7
Jena package
  • jena.model
  • Key package for application developer. It
    contains interfaces for model, resource,
  • jena.mem
  • Contains an implementation of Jena API which
    stores all model state in main memory
  • Jena.common
  • Contains implementation classes

8
Jena API Structure
9
Jena interfaces
  • Model a set of statements
  • Statement a triple of R, P, O
  • Resource subject, URI
  • Property item of resource
  • Object may be a resource or a literal
  • Literal non-nested object
  • Container special resource, collection of things

10
Jena interfaces (cont.)
11
Ex. 1 Create Resource
  • static String tutorialURI "http//hostname/rdf/t
    utorial/"
  • static String author "Brian McBride"
  • static String title "An Introduction to RDF and
    the Jena API"
  • static String date "23/01/2001"
  • Model model new ModelMem()
  • Resource tutorial model.createResource(tutorialU
    RI)
  • tutorial.addProperty(DC.creator, author)
  • tutorial.addProperty(DC.title, title)
  • tutorial.addProperty(DC.date, date)

12
Ex. 2 Go through Statements
  • StmtIterator iter model.listStatements()
  • while (iter.hasNext())
  • Statement stmt iter.next()
  • Resource subject stmt.getSubject()
  • Property predicate stmt.getPredicate()
  • RDFNode object stmt.getObject()
  • System.out.print("(" predicate.toString()
    ",")
  • System.out.print(" " subject.toString()
    ",")
  • if (object instanceof Resource)
  • System.out.print(" " object.toString())
  • else
  • System.out.print(" \"" object.toString()
    "\"") System.out.println(")")

13
Ex. 3 Read and Write File
  • Model model new ModelMem()
  • String filename temp/tutorial4.xml
  • Model.read(new FileReader(filename), )
  • Model.write(new PrintWriter(System.out))
  • // or
  • String output_filename temp/test.xml
  • Model.write(new PrintWriter(new
    FileOutputStream(output_filename)))

14
Ex. 4 Navigating a Model
  • Property email model.createProperty(tutorialURI,
    "emailAddress")
  • Resource tutorial model.getResource(tutorialURI)
  • Resource author tutorial.getProperty(DC.creator)
    .getResource()
  • StmtIterator iter author.listProperties(email)
  • while (iter.hasNext())
  • System.out.println(" " iter.next().getObject().
    toString())

15
Ex. 5 Querying a Model
  • ResIterator iter model.listSubjectsWithProperty(
    DC.date, date)
  • while (iter.hasNext())
  • cout ltlt iter.next().getProperty(DC.title)
    .getString()
  • NodeIterator iter2 model.listObjectsOfProperty(D
    C.creator)
  • while (iter2.hasNext())
  • cout ltlt ((Resource)iter2.next())
    .getProperty(name) .getString()

16
Containers
  • Represents collections of things
  • BAG unordered collection
  • ALT unordered collection except first element
  • SEQ ordered collection

17
Ex. 6 Containers
  • Bag bag model.createBag()
  • bag.add("Romeo and Juliet")
  • .add("Hamlet")
  • .add("Othello")
  • NodeIterator iter bag.iterator()
  • while (iter.hasNext())
  • System.out.println(" " iter.next().toString())
  • model.write(new PrintWriter(System.out))

18
References
  • Jena Web Site
  • http//www.hpl.hp.co.uk/people/bwm/index.html
  • Jena tutorial
  • http//bmcb.btinternet.co.uk/2001/rdf/jenatutorial
    /
  • http//www.xml.com/pub/a/2001/05/23/jena.html
  • RDF Model and Syntax Specification
  • http//www.w3.org/TR/1999/REC-rdf-syntax-19990222/

19
Thanks!
About PowerShow.com