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 #876 Updated term.py to add xsd:normalizedString and xsd:token support for Literals #1102

Merged
merged 7 commits into from Jul 12, 2021

Conversation

bhadoo-aditya
Copy link
Contributor

The lexical space of xsd:normalizedString is unconstrained (any valid XML character may be used). Its value space is the set of strings after whitespace replacement—i.e., after any occurrence of #x9 (tab), #xA (linefeed), and #xD (carriage return) have been replaced by an occurrence of #x20 (space) without any whitespace collapsing.
#876

@bhadoo-aditya bhadoo-aditya changed the title fix #856 Updated term.py. xsd:normalizedString support added to Literals fix #876 Updated term.py. xsd:normalizedString support added to Literals May 29, 2020
@coveralls
Copy link

coveralls commented May 29, 2020

Coverage Status

Coverage decreased (-0.005%) to 75.761% when pulling fedb4f7 on bhadoo-aditya:Sweb into 037ea51 on RDFLib:master.

@edmondchuc edmondchuc self-requested a review July 9, 2021 01:33
@edmondchuc edmondchuc self-assigned this Jul 9, 2021
@edmondchuc edmondchuc added this to the rdflib 6.0.0 release milestone Jul 9, 2021
@edmondchuc edmondchuc moved this from To do to In progress in RDFLib 6.0.0 release Jul 9, 2021
@edmondchuc
Copy link
Contributor

Merging this closes #876.

@edmondchuc edmondchuc linked an issue Jul 9, 2021 that may be closed by this pull request
@edmondchuc
Copy link
Contributor

Spec reference: https://www.w3.org/TR/xmlschema11-2/#normalizedString

xsd:token is a derived datatype of xsd:normalizedString. Therefore, this PR should also apply to xsd:token as well. See https://www.w3.org/TR/xmlschema11-2/#token

@edmondchuc
Copy link
Contributor

Note that while xsd:normalizedString has whiteSpace = replace, xsd:token instead has whiteSpace = collapse.

rdflib/term.py Outdated
Comment on lines 1644 to 1647
try:
return st.replace('\t',' ').replace('\n',' ').replace('\r',' ')
except:
return None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not clear why this needs to be in an try except.

@edmondchuc edmondchuc moved this from In progress to Ready for merge in RDFLib 6.0.0 release Jul 9, 2021
@edmondchuc edmondchuc changed the title fix #876 Updated term.py. xsd:normalizedString support added to Literals fix #876 Updated term.py to add xsd:normalizedString and xsd:token support for Literals Jul 9, 2021
@edmondchuc
Copy link
Contributor

This PR performs normalisation on xsd:normalizedString and xsd:token. For xsd:token, this PR also strips trailing whitespace (left and right) and replaces contiguous whitespace with a single whitespace.

Dockerfile base image version tag bumped from python:3.6 to python:3.7.

Improved some tests for xsd:normalizedString and added tests for xsd:token.

@edmondchuc edmondchuc removed this from the rdflib 6.0.0 release milestone Jul 9, 2021
@nicholascar nicholascar merged commit cd50cca into RDFLib:master Jul 12, 2021
@nicholascar nicholascar moved this from Ready for merge to Done in RDFLib 6.0.0 release Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

xsd:normalizedString support is not implemented
4 participants