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

Draft: SHACL derived from map #126

Open
wants to merge 1 commit into
base: issue_115_shapes
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions runtime-EclipseXtext/person-shapes/person-shapes.xrm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ base "https://schema.example.org/"

// this sample is inspired by https://w3c.github.io/shacl/shacl-compact-syntax/#example

node-shape PersonNodeShape {
node-shape PersonNodeShape from PersonMapping {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main change, which would have multiple effects:

  1. every property mapped in the the PersonMapping would automatically generate a Property Shape, even if not listed here
  2. properties would be suggested from the predicates mapped in properties
  3. target classes would be suggested based on the mapping types

// deactivated

target-classes
Expand All @@ -14,26 +14,29 @@ node-shape PersonNodeShape {
rdf.^type

properties
ex.ssn node-kind Literal [0..1] {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed node-kind because it would be implied from the the mapping itself

ex.ssn {
cardinality [0..1]
datatype xsd.string
pattern "^\\\\d{3}-\\\\d{2}-\\\\d{4}$"
}

ex.worksFor node-kind IRI [0..*] {
ex.worksFor {
cardinality [0..*]
classes ex.Company
pattern "^https://data.example.org/"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed because sh:pattern actually does not work with URLs

}

ex.address node-kind BlankNode [0..1] {
ex.address {
cardinality [0..1]
node-shapes AddressNodeShape
}

// this shows the union of all attributes in the expected order of appearance. note that combining all attributes like this doesn't make much sense.
ex.hasAnything node-kind Any [0..*] {
ex.hasAnything {
node-kind Any
cardinality [0..*]
Comment on lines +35 to +36
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to move node-kind and cardinality inside the block since I expect both would be optional

classes ex.Company
datatype xsd.string
node-shapes EmptyNodeShape
pattern "^https://data.example.org/"
}

// alternatively to embedded property shapes, also support the use of externalized property shapes
Expand All @@ -43,24 +46,33 @@ node-shape PersonNodeShape {

node-shape AddressNodeShape {
properties
ex.city node-kind Literal [1..1] {
ex.city {
node-kind Literal
cardinality [1..1]
datatype xsd.string
}

ex.postalCode node-kind Literal [1..1] {
ex.postalCode {
node-kind Literal
cardinality [1..1]
datatype xsd.string
}
}

node-shape EmptyNodeShape {
}

property-shape EmptyPropertyShape node-kind Any [0..*] {
property-shape EmptyPropertyShape {
node-kind Any
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that node-kind Any could actually be skipped unless its purpose is to override the default output derived from the mapping.

cardinality [0..*]
}

property-shape AddressPropertyShape node-kind BlankNode [0..1] {
property-shape AddressPropertyShape {
deactivated

node-kind BlankNode
cardinality [0..1]

path ex.address

node-shapes AddressNodeShape
Expand Down