Skip to content

Cannot parse charset parameter from "application/rdf+xml; charset=UTF-8" #1195

@palchicz

Description

@palchicz

I'm interacting with a sparql server that returns "application/rdf+xml; charset=UTF-8" as the response content-type when issuing a "construct" query.

This is causing the following stack-trace and exception

rdflib/graph.py:1121: in query
    **kwargs
rdflib/plugins/stores/sparqlstore.py:476: in query
    return SPARQLStore.query(self, *args, **kwargs)
rdflib/plugins/stores/sparqlstore.py:187: in query
    default_graph=queryGraph if self._is_contextual(queryGraph) else None)
rdflib/plugins/stores/sparqlstore.py:150: in _query
    return super(SPARQLStore, self).query(*args, **kwargs)
rdflib/plugins/stores/sparqlconnector.py:98: in query
    return Result.parse(BytesIO(res.content), content_type=res.headers['Content-type'])
rdflib/query.py:213: in parse
    return parser.parse(source, content_type=content_type, **kwargs)
rdflib/plugins/sparql/results/graph.py:17: in parse
    res.graph.parse(source, format=content_type)
rdflib/graph.py:1076: in parse
    parser = plugin.get(format, Parser)()

========
    def get(name, kind):
        """
        Return the class for the specified (name, kind). Raises a
        PluginException if unable to do so.
        """
        try:
            p = _plugins[(name, kind)]
        except KeyError:
            raise PluginException(
>               "No plugin registered for (%s, %s)" % (name, kind))
E           rdflib.plugin.PluginException: No plugin registered for (application/rdf+xml; charset=UTF-8, <class 'rdflib.parser.Parser'>)

I believe the issue can be resolved by changing this line https://github.com/RDFLib/rdflib/blob/master/rdflib/query.py#L206

# return parser.parse(source, content_type=content_type, **kwargs)
return parser.parse(source, content_type=plugin_key, **kwargs)

Metadata

Metadata

Assignees

Labels

SPARQLbugSomething isn't workingmarked for closingThe issue or PR will be closed soon if no further feedback is provided.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions