Reputation: 1425
I am trying to convert a file into XML using the N3 parser in RDFlib but I am not sure if I am doing it right or even if I have the n3 plugin installed. This is what I have so far:
import rdflib
from rdflib import URIRef, Graph, Namespace
from rdflib.plugins.parsers.notation3 import N3Parser
g = Graph()
result = g.parse(file=open("lemon_example_fear.txt", "r"), format="application/n3")
print (g.serialize(format='xml'))
This is not working but if I was to reverse the order with a working XML file it works fine
This is the error I get:
rdflib.plugin.PluginException: No plugin registered for (application/n3, <class 'rdflib.parser.Parser'>)
If anyone has a link to where to download the n3 plugin or just fix what I am doing wrong it would be great!
I am currently Running RDFlib 4.0.1 so it should be included shouldn't it?
Upvotes: 3
Views: 2234
Reputation: 85813
According to this answer to another one of your questions (in particular, check the list of available parsers link), the format argument would be n3
, not application/n3
. If you do need to use the MIME type for the argument, the N3 spec says that the MIME type should be text/n3
, not application/n3
.
Upvotes: 3