Barry Bishop
Wed, 11 Aug 2010 11:13:30 -0700
Hi Yonghong, A named graph is just that, a graph with a name. Sesame calls this name a 'context'.
The way named graphs behave is to extend the triple data model to a
quad, i.e. each statement is subject-predicate-object-context, where
'context' can be null.
To add a statement with a context, here is an example:
Repository repository = ....;
RepositoryConnection conn = repository.getConnection();
ValueFactory vf = repository.getValueFactory();
URI subj = vf.createURI("http://example.org/owlim#Pilot");
URI obj = vf.createURI("http://example.org/owlim#Human");
URI context = vf.createURI("http://example.org/owlim#People");
repositoryConnection.add(subj, RDF.TYPE, obj, context);
repositoryConnection.commit();
repositoryConnection.close();
I hope this helps,
barry
On 11/08/2010 18:09, yonghong ke wrote:
> /It seems/ that a sesame context is different from a named graph,
> isn't it?
> If i want to add a statement to a named graph,So how should do?
>
>
> 在 2010年8月4日 下午4:17,yonghong ke <kyh....@gmail.com
> <mailto:kyh....@gmail.com>>写道:
>
> Thank you very much,i'ill try what you said.
>
> 在 2010年8月2日 下午5:02,Jacek Kopecky <j.kope...@open.ac.uk
> <mailto:j.kope...@open.ac.uk>>写道:
>
> Hi Yonghong,
> a quick example adapted from the link sent by Barry:
>
> SELECT *
> FROM NAMED <http://example.org/example/example.rdf>
> WHERE { your graph pattern }
>
> This should just use the triples in that particular context.
> Hope it helps,
> Jacek
>
> On 2 Aug 2010, at 09:46, Barry Bishop wrote:
>
> > Hi Yonghong,
> >
> > If you have not done this before, probably the best place to
> start is to
> > read here:
> >
> > http://www.w3.org/TR/rdf-sparql-query/#namedGraphs
> >
> > You will need to use FROM or FROM NAMED or a combination of
> the two. I
> > won't explain further, as the above URL explains it better
> than I could.
> >
> > Best of luck,
> > barry
> >
> > --
> > Barry Bishop
> > OWLIM Product Manager
> > Ontotext AD
> > Tel: +43 650 2000 237
> > email: barry.bis...@ontotext.com
> <mailto:barry.bis...@ontotext.com>
> > www.ontotext.com <http://www.ontotext.com/>
> >
> > On 02/08/2010 10:31, yonghong ke wrote:
> >> Hi, all:
> >> I create a context like follow:
> >>
> >> String location = "http://example.org/example/example.rdf";
> >>
> >> URI context = f.createURI(location);
> >>
> >>
> >> con.add(sub, predicate, obj, context);
> >>
> >>
> >> i want to query in the ‘context’ use sparql, how should i do ?
> >>
> >> Thanks!
> >>
> >>
> >>
> >> _______________________________________________
> >> OWLIM-discussion mailing list
> >> OWLIM-discussion@ontotext.com
> <mailto:OWLIM-discussion@ontotext.com>
> >> http://ontotext.com/mailman/listinfo/owlim-discussion
> > _______________________________________________
> > OWLIM-discussion mailing list
> > OWLIM-discussion@ontotext.com
> <mailto:OWLIM-discussion@ontotext.com>
> > http://ontotext.com/mailman/listinfo/owlim-discussion
>
>
> --
> The Open University is incorporated by Royal Charter (RC
> 000391), an exempt charity in England & Wales and a charity
> registered in Scotland (SC 038302).
>
>
>
>
>
> _______________________________________________
> OWLIM-discussion mailing list
> OWLIM-discussion@ontotext.com
> http://ontotext.com/mailman/listinfo/owlim-discussion
_______________________________________________
OWLIM-discussion mailing list
OWLIM-discussion@ontotext.com
http://ontotext.com/mailman/listinfo/owlim-discussion