-
Notifications
You must be signed in to change notification settings - Fork 146
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
Turtle serializer shouldn't write blank nodes as <...> #555
Comments
I can confirm that <_:b0> is a NamedNode, not a BlankNode in Turtle. So this looks like a bug. |
Agreed. The issue may be in JSON-LD parser and not in turtle serializer. |
Thx for the hint. So I tried to first convert from JSON-LD to N-Quads (with another library, jsonld) and then convert to Turtle. Which helped by embedding the blank nodes. So the blank node labels may still be wrong, I couldn't test this, but my problem is solved for now. |
This is rather problematic for any system that uses rdflib.js to parse JSON-LD. Any chance this can get prioritized? |
I can confirm that e.g. the following JSON-LD is not parsed correctly: {
"@context": {
"@vocab": "https://example.com/"
},
"hasExampleProperty": "some literal value"
} Results in the following statement (I'm using an example IRI for the graph here): {
"subject": {
"termType": "NamedNode",
"classOrder": 5,
"value": "_:b0"
},
"predicate": {
"termType": "NamedNode",
"classOrder": 5,
"value": "https://example.com/hasExampleProperty"
},
"object": {
"termType": "Literal",
"classOrder": 1,
"value": "some literal value",
"datatype": {
"termType": "NamedNode",
"classOrder": 5,
"value": "http://www.w3.org/2001/XMLSchema#string"
},
"isVar": 0,
"language": ""
},
"graph": {
"termType": "NamedNode",
"classOrder": 5,
"value": "https://example.com/test/"
}
} But clearly Whereas the corresponding Turtle, is parsed correctly:
Becomes: {
"subject": {
"termType": "BlankNode",
"classOrder": 6,
"value": "_g_L2C39",
"isBlank": 1,
"isVar": 1
},
"predicate": {
"termType": "NamedNode",
"classOrder": 5,
"value": "https://example.com/hasExampleProperty"
},
"object": {
"termType": "Literal",
"classOrder": 1,
"value": "some literal value",
"datatype": {
"termType": "NamedNode",
"classOrder": 5,
"value": "http://www.w3.org/2001/XMLSchema#string"
},
"isVar": 0,
"language": ""
},
"graph": {
"termType": "NamedNode",
"classOrder": 5,
"value": "https://example.com/test/"
}
} (Interestingly, the blank node gets a completely different internal identifier in this case). |
When the JSON-LD contains a list, the blank nodes corresponding to that collection are generated correctly: {
"@context": {
"@vocab": "https://example.com/",
"hasExampleProperty": {
"@container": "@list"
}
},
"hasExampleProperty": ["some literal value", "some other literal value"]
} As N-Quads:
|
The function Line 11 in c14dfd5
|
DiagnosisIt looks like the The JSON-LD parser takes the flattened output, and checks for Lines 68 to 83 in c14dfd5
and: Lines 24 to 26 in c14dfd5
However, the
This turns the node into a The The flattened output (also non-normative) uses this in its examples: https://www.w3.org/TR/json-ld11/#flattened-document-form (and it needs to as it cannot use nesting to group the properties of the node together). Proposed Solution
|
I'm converting JSON-LD to Turtle using rdflib.js.
Example input:
Example current output out of rdflib.js:
Turtle spec states following:
So, I think blank nodes should be expressed without <...>, because this makes them absolute or relative IRIs and not blank nodes.
As an additional feature, it would be nice to be able to control the blank node output to have them nested or not nested.
Questions:
Many thanks.
The text was updated successfully, but these errors were encountered: