Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Linkset JSON as JSON-LD https://github.com/dret/I-D/issues/119
{
"@context": [
{
"@vocab": "https://www.iana.org/assignments/link-relations/",
"anchor": "@id",
"href": "@id",
"dct": "http://purl.org/dc/terms/",
"link": "https://www.iana.org/assignments/link-relations#",
"title": {
"@id": "http://purl.org/dc/terms/title"
},
"title*": {
"@id": "http://purl.org/dc/terms/title"
},
"type": {
"@id": "dct:format",
"@type": "@vocab"
}
},
{
"language": "@language",
"value": "@value",
"hreflang": {
"@id": "https://www.w3.org/ns/activitystreams#hreflang",
"@container": "@set"
}
}
],
"linkset": [
{
"anchor": "https://example.org/article/view/7507",
"author": [
{
"href": "https://orcid.org/0000-0002-4311-0897",
"type": "rdf/xml"
}
],
"item": [
{
"href": "https://example.org/article/7507/item/1",
"type": "application/pdf"
},
{
"href": "https://example.org/article/7507/item/2",
"type": "text/csv"
}
],
"cite-as": [
{
"href": "https://doi.org/10.841/zk2557"
}
]
},
{
"anchor": "https://example.com/links",
"alternate": [
{
"href": "https://mirror.example.com/links"
}
]
}
]
}
<https://example.com/links> <https://www.iana.org/assignments/link-relations/alternate> <https://mirror.example.com/links> .
<https://example.org/article/7507/item/1> <http://purl.org/dc/terms/format> <https://www.iana.org/assignments/link-relations/application/pdf> .
<https://example.org/article/7507/item/2> <http://purl.org/dc/terms/format> <https://www.iana.org/assignments/link-relations/text/csv> .
<https://example.org/article/view/7507> <https://www.iana.org/assignments/link-relations/author> <https://orcid.org/0000-0002-4311-0897> .
<https://example.org/article/view/7507> <https://www.iana.org/assignments/link-relations/cite-as> <https://doi.org/10.841/zk2557> .
<https://example.org/article/view/7507> <https://www.iana.org/assignments/link-relations/item> <https://example.org/article/7507/item/1> .
<https://example.org/article/view/7507> <https://www.iana.org/assignments/link-relations/item> <https://example.org/article/7507/item/2> .
<https://orcid.org/0000-0002-4311-0897> <http://purl.org/dc/terms/format> <https://www.iana.org/assignments/link-relations/rdf/xml> .
_:b0 <https://www.iana.org/assignments/link-relations/linkset> <https://example.com/links> .
_:b0 <https://www.iana.org/assignments/link-relations/linkset> <https://example.org/article/view/7507> .
@hvdsomp

This comment has been minimized.

Copy link

commented Feb 28, 2019

Looks like type is also misinterpreted. Its value is rendered as a link relation URI rather than as a format string, eg <https://www.iana.org/assignments/link-relations/application/pdf> instead of "application/pdf"

@BigBlueHat

This comment has been minimized.

Copy link

commented Mar 12, 2019

Try adding "linkset": "@graph" to the @context, and it should get you the triples you want:

<https://example.com/links> <https://www.iana.org/assignments/link-relations/alternate> <https://mirror.example.com/links> .
<https://example.org/article/7507/item/1> <http://purl.org/dc/terms/format> <https://www.iana.org/assignments/link-relations/application/pdf> .
<https://example.org/article/7507/item/2> <http://purl.org/dc/terms/format> <https://www.iana.org/assignments/link-relations/text/csv> .
<https://example.org/article/view/7507> <https://www.iana.org/assignments/link-relations/author> <https://orcid.org/0000-0002-4311-0897> .
<https://example.org/article/view/7507> <https://www.iana.org/assignments/link-relations/cite-as> <https://doi.org/10.841/zk2557> .
<https://example.org/article/view/7507> <https://www.iana.org/assignments/link-relations/item> <https://example.org/article/7507/item/1> .
<https://example.org/article/view/7507> <https://www.iana.org/assignments/link-relations/item> <https://example.org/article/7507/item/2> .
<https://orcid.org/0000-0002-4311-0897> <http://purl.org/dc/terms/format> <https://www.iana.org/assignments/link-relations/rdf/xml> .
@stain

This comment has been minimized.

Copy link
Owner Author

commented Mar 13, 2019

Yes, @BigBlueHat, that would work, except then you can't use "linkset" as an inner relation type, which is a bit odd given that this RFC would introduce that relationship.. So if we combine your trick with also calling the outer key @linkset instead of linkset we are good to go without needing to use JSON-LD 1.1 (which is still in draft stages)

@stain

This comment has been minimized.

Copy link
Owner Author

commented Mar 13, 2019

About type I think we can't use @vocab trick here as it should map to some base URI for formats, like https://www.iana.org/assignments/media-types/ making https://www.iana.org/assignments/media-types/text/html etc -- but IANA never managed to decide on such a base URI. In addition that would mean format would not work with parameters like charset.

That means we should not use dct:format - which is defined with range http://purl.org/dc/terms/MediaTypeOrExtent aka an object property to a URI resource - but rather the more simple dc:format which allows plain literals. Then simply remove @type for format. That is how we mapped mediatype in https://researchobject.github.io/specifications/bundle/#json-ld

@BigBlueHat

This comment has been minimized.

Copy link

commented Mar 13, 2019

Yeah...don't introduce any new @ prefixed terms... That'll run into issues in the future for sure.

In digging a bit more, I think "linkset": {"@container": "@list"} gets a more correct result. It preserves the "linkset" relationship between multiple blank nodes: one for the linkset and one for each of the contained links (in this example).

@BigBlueHat

This comment has been minimized.

Copy link

commented Mar 13, 2019

Also, excellent points about format. We used dc:format (for likely very similar reasons) in the Web Annotation Data Model spec's context file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.