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

Literal.datatype doesn't get initialized for Turtle string #670

Open
nabito opened this issue Nov 25, 2016 · 1 comment · May be fixed by #2460
Open

Literal.datatype doesn't get initialized for Turtle string #670

nabito opened this issue Nov 25, 2016 · 1 comment · May be fixed by #2460
Assignees
Labels
breaking change This involves or proposes breaking RDFLib's public API. bug Something isn't working concept: datatype Relates to the RDF literal datatype concept. concept: RDF Literal core Relates to core functionality of RDFLib, i.e. `rdflib.{graph,store,term}` duplicate This issue or pull request already exists enhancement New feature or request parsing Related to a parsing. serialization Related to serialization.

Comments

@nabito
Copy link

nabito commented Nov 25, 2016

Say we've this RDF statement in Turtle:

ex:obs3 ex:hasStatus "online" .

At rdflib 4.2.1 rdflib.term.Literal does not init 'datatype' attr for string type if not explicitly written as "value"^^xsd:string. As per W3C specification of Turtle, writing just "value" implicitly means it's xsd:string.

This assignment is needed for the program logic to be consistent when expecting to check for literal type using such attribute.

The attribute get updated for other types like decimal, integer without explicitly written in Turtle.

@gromgull gromgull added this to the rdflib 5.0.0 milestone Jan 12, 2017
@joernhees joernhees added enhancement New feature or request parsing Related to a parsing. serialization Related to serialization. labels Jan 19, 2017
@white-gecko white-gecko modified the milestones: rdflib 5.0.0, rdflib 5.1.0 Apr 6, 2020
@white-gecko white-gecko modified the milestones: rdflib 5.1.0, rdflib 6.0.0 May 1, 2020
anubhavj99 added a commit to anubhavj99/rdflib that referenced this issue May 25, 2020
saksham16085 added a commit to anubhavj99/rdflib that referenced this issue May 26, 2020
1. Handled case for None datatype for a Literal
2. Updated test cases in files: describer.py, container.py, graph.py, resource.py, term.py
saksham16085 added a commit to anubhavj99/rdflib that referenced this issue May 27, 2020
1. changed check for no datatype in nt.py
2. Updated test cases in files: test_issue655.py, test_literal.py, test_prettyxml.py, test_serializexml.py
@saksham16085
Copy link

I had started working on this issue. My proposed solution was to check if datatype was none while returning the call to self._datatype.
This lead to a number of errors and failures, since:

  1. According to rdflib library, only one of language or datatype property should be present, and they have chosen to save the language attribute while storing a string. which leaves no other option than setting datatype to None.
  2. Forcefully setting the datatype attribute leads to several failures and errors, many test cases rely on the fact that there should be no datatype attribute attached to the Literal if it is a string. There are also differences in the serialized graphs returned by the serialize function, where there didn't contain datatype attribute in any of the string literals.

The changes mentioned are done in the Literal class of term.py

@ghost ghost added the duplicate This issue or pull request already exists label Jan 2, 2022
@aucampia aucampia added bug Something isn't working core Relates to core functionality of RDFLib, i.e. `rdflib.{graph,store,term}` breaking change This involves or proposes breaking RDFLib's public API. labels May 22, 2023
@aucampia aucampia self-assigned this Jun 11, 2023
@aucampia aucampia added the concept: datatype Relates to the RDF literal datatype concept. label Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change This involves or proposes breaking RDFLib's public API. bug Something isn't working concept: datatype Relates to the RDF literal datatype concept. concept: RDF Literal core Relates to core functionality of RDFLib, i.e. `rdflib.{graph,store,term}` duplicate This issue or pull request already exists enhancement New feature or request parsing Related to a parsing. serialization Related to serialization.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants