Christian Bizer

Richard Cyganiak

E. Rowland Watkins

Freie Universität Berlin Freie Universität Berlin
Berlin, Germany
Berlin, Germany
chris@bizer.derichard@cyganiak.de

University of Southampton
Southampton, UK
erw01r@ecs.soton.ac.uk

NG4J – Named Graphs API for Jena
Named Graphs
Named Graphs are a simple extension to the RDF abstract syntax and enable statements tobe made about RDF graphs. This is beneficial for applications like data syndication, provenance tracking, ontology versioning, signing RDF, and access control to parts of RDF repositories. Named Graphs form the basis for SPARQL, W3C's upcoming RDF query language.
NG4J
The Named Graphs API for Jena is
an implementation of Named Graphs
on top of the Jena Semantic Web
Framework. NG4J extends Jenawith:• graph- and quad-centric methods for
manipulating sets of Named Graphs

NamedGraphSet
getGraph(uri)addGraph(namedGraph)removeGraph(namedGraph)
listGraphs()
findQuads(g, s, p, o)read(uri, lang)write(writer, lang)merge

NamedGraphgraphName*find(s, p, o)add(s, p, o)remove(s, p, o)NamedGraphModel
listStatements(s, p, o)• Jena Model view on a graphset's merge• provenance-enabled Jena Statements

NamedGraphSetMem• TriQL query language for queries acrossgraphs

NamedGraphSetDB• parsers and serializers for the TriG andTriX syntaxes, including support for TriX
syntactic extensions with XSLTSWPNamedGraphSet
swpAssert(authority)
swpQuote(authority)
assertWithSignature(...)
quoteWithSignature(...)
verifyAllSignatures()• database-persisted graphset storage• API support for the Semantic Web
Publishing (SWP) vocabulary*NamedGraph
Statementsubject
predicateobject
listGraphs()

NG4J• creation and verification of graphsignatures using X.509 certificates

Jenaimplements

Modelimplements

Statementimplements

Graph

TriGTriXTriQL

A serialization format for sets ofNamed Graphs, based on Turtle

A serialization format for RDF andsets of Named Graphs that plays
well with XML tools. An XSLTbased extension mechanism canbe used to define more concise
variations of the syntax.

A language for queries acrossNamed Graphs, based on RDQL.
The example fetches all email
addresses of Bob that have beenasserted by Alice in 2005, withthe respective graph names.
In NG4J, TriQL queries are
executed against instances of
the NamedGraphSet class.

@prefix swp: <http://www.w3.org/…/swp-2/>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix : <http://example.org/>.
:G1 {:Bob foaf:mbox <mailto:bob@example.org>.
}:G2 {:Bob foaf:mbox <mailto:bob2@example.com>.
}:warrant {:warrant a swp:Warrant.
:warrant swp:authority :Alice.
:warrant swp:signatureMethod
swp:JjcRdfC14N-rsa-sha1.
:warrant swp:signature"E2aylV…"^^xsd:base64Binary.
:warrant swp:assertedBy :warrant.
:G1 swp:assertedBy :warrant.
:G1 swp:digestMethod swp:JjcRdfC14N-sha1.
:G1 swp:digest "YjRhNz…"^^xsd:base64Binary.
:G2 swp:quotedBy :warrant.
:G2 swp:digestMethod swp:JjcRdfC14N-sha1.
:G2 swp:digest "NmM2NW…"^^xsd:base64Binary.
}<TriX xmlns="http://www.w3.org/2004/03/trix/trix-1/"><graph><uri>http://example.org/graph1</uri><triple><uri>http://example.org/aBook</uri><uri>http://example.org/title</uri><plainLiteral>A Good Book</plainLiteral></triple></graph><graph><uri>http://example.org/graph2</uri><triple><uri>http://example.org/graph1</uri><uri>http://example.org/source</uri><uri>http://example.org/books.rdf</uri></triple></graph></TriX>

SELECT ?email, ?source
WHERE ?source (ex:Bob foaf:mbox ?email)?warrant (?source swp:assertedBy ?warrant.
?warrant swp:authority :Alice.
?warrant dc:date ?date)
AND ?date >= "2005-01-01"^^xsd:date
AND ?date < "2006-01-01"^^xsd:date
USING
ex FOR <http://example.org/>
foaf FOR <http://xmlns.com/foaf/0.1/>
swp FOR <http://www.w3.org/…/swp-2/>
dc FOR <http://purl.org/dc/elements/1.1/>

Further information about NG4J and download: http://www.wiwiss.fu-berlin.de/suhl/bizer/ng4j/