RDFLib / rdflib-jsonld

JSON-LD parser and serializer plugins for RDFLib
Other
283 stars 71 forks source link

base is None when the context is a relative IRI #26

Open pebbie opened 10 years ago

pebbie commented 10 years ago

when the load method of a context object is called (parser.py:83), variable base is None although in the parser.py:80 the base is already set in the constructor.

this caused reading a jsonld document of a hydra api demo in (http://www.markus-lanthaler.com/hydra/api-demo/) ended up in a failure as relative IRI stated in the @context /hydra/api-demo/context/EntryPoint.jsonld is interpreted as local file source.

adding 2 lines below in the beginning of load method (context.py:37) fixes the problem.

if base is None and self.base is not None:
            base = self.base
niklasl commented 10 years ago

Could you provide the code call which causes the problem? The following seems to work without this change:

from rdflib import *
import sys
Graph().parse(
        "http://www.markus-lanthaler.com/hydra/api-demo/", format='json-ld').serialize(
                sys.stdout, format='turtle')

(Or perhaps the example data has changed?)