Skip to content

Retrieve content of a BNode #157

Answered by pchampin
rracariu asked this question in Q&A
Discussion options

You must be logged in to vote

Triples are not "inside" a node (blank or otherwise). The square brackets are just a shortcut to spare you the trouple of "labelling" the blank node, but internally, all blank node get an arbitrary label. So your Turtle is equivalent to:

ex:Foo a owl:Class .
ex:Foo a sh:NodeShape .
ex:Foo sh:property _:b .
_:b sh:class ex:Bar .
_:b sh:path ex:somePath .

In order to get all the triples from a graph g whose subject is a given blank node bn that you got, you can use Graph::triples_matching. For example:

for triple in g.triples_matching([b], Any, Any) {
  // do something with the triple
}

A more elaborate example would be:

    let mut graph: LightGraph = turtle::parse_str(your_data).collect_t…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rracariu
Comment options

Answer selected by rracariu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants