oole
oole

Reputation: 352

What is the proper universal way of inserting blank nodes using SPARQL

I am writing an application using the Apache Jena framework. With this I am able to do everything (insert, update, select). But i can't wrap my head around how to properly insert blank nodes using an INSERT query.

Is there a go-to approach for this (which works with every endpoint)? I know SPARQL 1.1 introduced some features for this to be accomplished, but it does not seem to work using a Virtuoso endpoint.

Upvotes: 4

Views: 1731

Answers (1)

scotthenninger
scotthenninger

Reputation: 4001

There are a couple of syntaxes to use. Suppose you want to add a bnode of type :Person to an object property named child. Here's one way:

?s :child [a :Person] .

And another:

?s :child [] .
[] a :Person .

And the _:bn notation is pretty universal, and useful when there are more than one bnode in a graph:

?s :child _:b0 .
_:b0 a :Person .

Upvotes: 3

Related Questions