Skip to content

Plugin store rdf4j cannot handle BNode #3342

@thomaslcde

Description

@thomaslcde

Hello.

I use_rdflib[rdf4j]>=7.5.0_ downloaded yesterday. It seems when store=RDF4J we cannot handle Bnode.

  server = Dataset(store=RDF4JStore(base_url="http://localhost:7000/rdf4j-server/", repository_id=REPO_ID))
  NAME = Namespace("http://example.com/#")
  id = NAME.term("subject")
  graph_name = NAME.term("Agraph")
  server.bind("name", NAME)
  g = Graph(identifier=graph_name, store=server.store)
  g.add((id, RDF.type, Literal("Object")))
  bn = BNode()
  g.add((bn, RDF.type, RDF.Seq))
  g.add((id, NAME.alist, bn))
  print(server.serialize(format="trig"))

Here is a simple piece of code, the last line cannot serialize the dataset because there is a bnode in the graph.
Its works fine with store=Memory().
I tested with a docker compose and testcontainers, the image is eclipse/rdf4j-workbench:5.2.0-tomcat

The error is the follow:

  File "Somehere/.venv/lib/python3.13/site-packages/rdflib/contrib/rdf4j/util.py", line 179, in validate_no_bnodes
ValueError: Subject, predicate, and object must not be a BNode: Na739021968584714bc4992b050f7ab81, None, None

Why can't we use Bnode with rdf4j ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions