Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turtle serializer: @base directive isn't added #559

Closed
danmichaelo opened this issue Nov 30, 2015 · 7 comments
Closed

Turtle serializer: @base directive isn't added #559

danmichaelo opened this issue Nov 30, 2015 · 7 comments
Labels
enhancement New feature or request serialization Related to serialization.
Milestone

Comments

@danmichaelo
Copy link

When doing graph.serialize(stream, base='...'), the @base directive isn't added.

I found a mention of this in #248 (comment) by @gromgull :

I left it without @base directive now - this way you can quickly and easily 'rebase' some triples.

but I find this slightly counterintuitive.

@lrowe
Copy link
Contributor

lrowe commented Dec 9, 2015

Neither is xml:base added when serializing as xml:

>>> g = rdflib.Graph()
>>> g.add((rdflib.URIRef('http://example.com/foo'), rdflib.URIRef('http://example.com/term'), rdflib.URIRef('http://example.com/bar')))
>>> print(g.serialize(format='xml', base='http://example.com').decode('utf-8'))
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
   xmlns:ns1="http://example.com/"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
  <rdf:Description rdf:about="/foo">
    <ns1:term rdf:resource="/bar"/>
  </rdf:Description>
</rdf:RDF>

@wikier
Copy link
Member

wikier commented Oct 5, 2016

any update on this?

@chrysn
Copy link
Contributor

chrysn commented Oct 27, 2016

i do see use cases where having @base would be good (for readability and compactness), but there are use cases when i very much prefer it not to be explicit, namely all situations in which statements are created by reasoning about local files and then exported in a http:// and not a file:// context.

if this issue does get fixed, i suggest that @base only gets added to the turtle serialization if an explicit_base=True argument is present.

@gromgull gromgull added enhancement New feature or request serialization Related to serialization. labels Jan 24, 2017
@joernhees joernhees added this to the rdflib 5.0.0 milestone Jan 26, 2017
@bhavye9499
Copy link

bhavye9499 commented Mar 31, 2020

Hi...Can I work this issue? It seems pretty straightforward. I would love to communicate with the maintainers regarding the same.

@white-gecko
Copy link
Member

If there are no objections to adding this feature, maybe as @chrysn suggests, you are welcome. We are happy about any pull-request helping us to fix bugs. We will have to see in which milestone it will be released.

@achaudhary997
Copy link
Contributor

This issue seems to have been fixed. rdflib version 5.0

>>> from rdflib import graph
>>> g = rdflib.Graph()
>>> g.add((rdflib.URIRef('http://example.com/foo'), rdflib.URIRef('http://example.com/term'), rdflib.URIRef('http://example.com/bar')))
>>> print(g.serialize(format='ttl', base='http://example.com').decode('utf-8'))
@base <http://example.com> .
@prefix ns1: <http://example.com/> .

</foo> ns2:term ns2:bar .

@ghost
Copy link

ghost commented Dec 26, 2021

As observed by achaudhary997, no longer an issue

@ghost ghost closed this as completed Dec 26, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request serialization Related to serialization.
Projects
None yet
Development

No branches or pull requests

9 participants