-
Notifications
You must be signed in to change notification settings - Fork 14
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
Issues with returning typed literals #25
Comments
When I developed this I mainly worked against virtuoso, so it might be somethign specific for that implementation. If you manage to make it work for both literal and typed-literal with datatype I will probably merge it. I belive this is the spec: https://www.w3.org/TR/2013/REC-sparql11-results-json-20130321/ Edit: according to above document, this "typed-literal" was something in earlier version of the spec, and not recommended anymore:
So I guess its due to the age of this package, almost 10 years since I started, only working against openlink virtuoso at the time. |
I am currently on a project where I'm not working with virtuoso, and it probably makes sense to test this against multiple systems before merging it. Will come back to this a bit later down the line. |
So, I had a look at what Virtuoso is doing, at least in the open source version, which is the only one I have access to. When I run a simple query like SELECT 32 WHERE {} it returns (as JSON): { "head": { "link": [], "vars": ["callret-0"] }, So we see that Virtuoso still uses the old "typed-literal" value. The way I implemented things in my fork, it simply checks for values with type "literal" whether "datatype" is defined, and then simply recovers this value, instead of using xsd:string as the type, like the old code did. And the behaviour for "typed-literal" is of course unchanged. If this solution sounds acceptable, then I could prepare a Pull Request. |
Sounds good to me! |
Hello,
I notice that knakk/sparql only returns typed literals when the JSON bindings from the Sparql endpoint actually have as type "typed-literal". I notice that GraphDB a supposedly standard compliant Sparql database, never returns "typed-literal" as the type of literals, only ever "literal". Here an example:
{
"head" : {
"vars" : [
"sub",
"path",
"ClosedObjTest"
]
},
"results" : {
"bindings" : [
{
"sub" : {
"type" : "uri",
"value" : "http://datashapes.org/sh/tests/core/complex/personexample.test#Calvin"
},
"path" : {
"type" : "uri",
"value" : "http://datashapes.org/sh/tests/core/complex/personexample.test#birthDate"
},
"ClosedObjTest" : {
"datatype" : "http://www.w3.org/2001/XMLSchema#date",
"type" : "literal",
"value" : "1999-09-09"
}
}
]
}
}
Note that "ClosedObjTest" is a "literal", but still has type date. This causes the Term that is parsed from this JSON to drop the type and just have string. I'm not sure if this is a problem with this package, or with GraphDB, but at any rate it seems to me that the most pragmatic solution is to check if the binding returns a "datatype" that is not string, and to carry that information when producing the Term struct.
Not sure if the solution I outline above is desirable. I will fork and implement this "hotfix" of sorts for my project and I could make it into a pull request if that's wanted.
The text was updated successfully, but these errors were encountered: