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

canonize xsd:duration #10

Open
VladimirAlexiev opened this issue Aug 30, 2018 · 2 comments
Open

canonize xsd:duration #10

VladimirAlexiev opened this issue Aug 30, 2018 · 2 comments

Comments

@VladimirAlexiev
Copy link

Related to BorderCloud/TFT-tests#15, it would be useful to canonize xsd:duration, xsd:yearMonthDuration, xsd:dayTimeDuration.

I tried with jsonld-cli and a duration like "PT1M0.000S"^^<http://www.w3.org/2001/XMLSchema#duration>
is not normalized to "PT1M"^^<http://www.w3.org/2001/XMLSchema#duration> (removing the empty seconds).

If jsonld-cli doesn't use this library, please accept my apologies and point me to the right repo.

@davidlehn
Copy link
Member

The jsonld.js and rdf-canonize code are just processing the input given. They don't do datatype specific processing other than for primitive JSON types. I'm unsure if we want to start adding such specific features to these libraries. It could lead to lots of custom special case code that could have a performance impact in cases where it's not needed. For time times it might requiring pulling in new libraries too. Are canonical forms specified for duration types? Seems the easiest solution is to just let applications do their own normalization and validation. This could be done with a library that handles these common datatypes. A related possibility is to add one or more optional hooks to do per-quad processing and hook that into some external library. I'm not sure if that would be in rdf-canonize or toRdf in jsonld.js. Thoughts?

@VladimirAlexiev
Copy link
Author

See https://gist.github.com/VladimirAlexiev/8ab96978c46dbc3a53298a2f0475cefe for what we want to do. The purpose is to decrease false "failed test" reports on SparqlScore.com to a minimum.

Your lib normalizes things like blank nodes, xsds:tring vs "plain literal", even 1e6 vs 1.0E6.
However, I'm not sure "primitive JSON types" is by the book. It converted 1e6 (xsd:decimal) to 1000000 (xsd:integer), and I'm not sure canonization is supposed to change the datatype.

Bringing in libs to handle extra XSD types sounds like the right approach. The performance impact will be minimal, because these are simple conversions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants