Skip to content

Instantly share code, notes, and snippets.

@michaelcpuckett
Last active February 12, 2020 00:18
Show Gist options
  • Save michaelcpuckett/6ec41b45f06219978e9f0d5c55ca2cb6 to your computer and use it in GitHub Desktop.
Save michaelcpuckett/6ec41b45f06219978e9f0d5c55ca2cb6 to your computer and use it in GitHub Desktop.
{
"@context": {
"schema": "http://schema.org/",
"sh": "http://www.w3.org/ns/shacl#",
"as": "https://www.w3.org/TR/activitystreams-core/"
},
"@type": "schema:ReadAction",
"schema:object": {
"@id": "schema:Article"
},
"schema:target": "http://example.com/graph",
"schema:result": {
"@type": "sh:NodeShape",
"sh:targetClass": {
"@id": "as:OrderedCollection"
},
"sh:property": {
"@type": "sh:PropertyShape",
"sh:path": {
"@id": "as:orderedItems"
},
"sh:values": {
"sh:orderBy": {
"sh:nodes": {
"@type": "sh:NodeShape",
"sh:path": [
{
"@id": "schema:interactionStatistic"
},
{
"@id": "schema:userInteractionCount"
}
]
}
}
},
"sh:node": {
"@type": "sh:NodeShape",
"sh:class": {
"@id": "schema:Article"
},
"sh:property": [
{
"@type": "sh:PropertyShape",
"sh:path": {
"@id": "schema:author"
}
},
{
"@type": "sh:PropertyShape",
"sh:path": {
"@id": "schema:headline"
}
},
{
"@type": "sh:PropertyShape",
"sh:path": {
"@id": "schema:interactionStatistic"
},
"sh:node": {
"@type": "sh:NodeShape",
"sh:class": {
"@id": "schema:InteractionCounter"
},
"sh:property": [
{
"@type": "sh:PropertyShape",
"sh:path": {
"@id": "schema:interactionType"
},
"sh:node": {
"@type": "sh:NodeShape",
"sh:class": {
"@id": "schema:CommentAction"
}
}
},
{
"@type": "sh:PropertyShape",
"sh:path": {
"@id": "schema:userInteractionCount"
}
}
]
}
}
]
}
}
}
}
@HolgerKnublauch
Copy link

This goes beyond what the SHACL spec says or what SHACL has been originally designed for. RDF data is inherently unordered. So you can make up the semantics of ordering as you want. I guess you could just as well introduce your own property instead of sh:orderBy, since then you don't really need to pay attention to the whole complexity of triple rules etc.

If you want to define property shapes to "walk" down a structure, using sh:node, then you'd only really need target statements for the root level, not the nested ones like "sh:targetClass": "schema:InteractionCounter" IMHO.

FWIW we heavily use Property Value Rules https://w3c.github.io/shacl/shacl-af/#PropertyValueRule to dynamically compute values, and those support sh:orderBy too.

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