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

fix: handling of rdf:HTML literals #2490

Merged
merged 2 commits into from Jul 19, 2023

Conversation

aucampia
Copy link
Member

Summary of changes

Previously, if without html5lib installed, literals withrdf:HTML datatypes were treated as
ill-typed, even if they were not ill-typed.

With this change, if html5lib is not installed, literals with the rdf:HTML datatype will not be treated as ill-typed, and will have Null as their ill_typed attribute value, which means that it is unknown whether they are ill-typed or not.

This change also fixes the mapping from rdf:HTML literal values to lexical forms.

Other changes:

  • Add tests for rdflib.NORMALIZE_LITERALS to ensure it behaves correctly.

Related issues:

Checklist

  • Checked that there aren't other open pull requests for
    the same change.
  • Checked that all tests and type checking passes.
  • Considered granting push permissions to the PR branch,
    so maintainers can fix minor issues and keep your PR up to date.

Previously, if without `html5lib` installed, literals with`rdf:HTML`
datatypes were treated as
[ill-typed](https://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal),
even if they were not ill-typed.

With this change, if `html5lib` is not installed, literals with the
`rdf:HTML` datatype will not be treated as ill-typed, and will have
`Null` as their `ill_typed` attribute value, which means that it is
unknown whether they are ill-typed or not.

This change also fixes the mapping from `rdf:HTML` literal values to
lexical forms.

Other changes:

- Add tests for `rdflib.NORMALIZE_LITERALS` to ensure it behaves
  correctly.

Related issues:

- Fixes <RDFLib#2475>
@coveralls
Copy link

coveralls commented Jul 16, 2023

Coverage Status

coverage: 90.925% (-0.001%) from 90.926% when pulling cc9e59f on aucampia:aucampia/20230709T2219-test-html5lib into 6981c28 on RDFLib:main.

@aucampia aucampia requested a review from a team July 16, 2023 17:34
@aucampia aucampia added review wanted This indicates that the PR is ready for review ready to merge The PR will be merged soon if no further feedback is provided. labels Jul 16, 2023
@aucampia
Copy link
Member Author

@WhiteGobo if you have a moment for a review please have a look.

@WhiteGobo
Copy link
Contributor

WhiteGobo commented Jul 16, 2023

Looks good to me. I find the idea to load the parser only if html5lib exists good.
I was only confused by one of the tests but as far as ive seen this is in line with, how other normalization tests of literals are done.

@aucampia aucampia merged commit 588286b into RDFLib:main Jul 19, 2023
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
concept: RDF Literal fix Fixes an issue ready to merge The PR will be merged soon if no further feedback is provided. review wanted This indicates that the PR is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Casting literal with content to rdf:HTML datatype leads incorrectly to empty literal
3 participants