Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.
Open
Changes from 10 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
59 changes: 46 additions & 13 deletions shacl-compact-syntax/scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,67 @@ Note that this should be done *after* these features have been supported by the

## New Features

### Support for additional SHACL-C shorthands
- Support Rules
- Support (SPARQL) Functions
- Support shorthand (`<`, `=`, `<=`, etc.) for property pair constraints
- [Support `xone` and more `or` cases](https://github.com/w3c/shacl/issues/12)
- Opting out of the production of the triple `?baseUri rdf:type owl:Ontology`
- Support for non-validating characteristics (e.g., generating `sh:order` triples by declaring `@order` at the top of a file/shape, allow grouping by `@group` at the top of a set of properties, and allowing a `@description` above properties).
### Support for Additional SHACL-C Constructs
- shorthand (`<`, `=`, `<=`, etc.) for property pair constraints
- [Support `xone` and more `or` cases](https://github.com/w3c/shacl/issues/12)
- Opt out of the production of the triple `?baseUri rdf:type owl:Ontology`
- Non-validating characteristics (e.g., generating `sh:order` triples by declaring `@order` at the top of a file/shape, allow grouping by `@group` at the top of a set of properties, and allowing a `@description` above properties).
- Target shapes, see [rsx:targetShape](https://rdf4j.org/shacl/extensions.html)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this would only be appropriate if rsx:targetShape becomes part of the SHACL or SHACL-AF. Is there an effort to incorporate rsx: features into SHACL or SHACL-AF as part of the 1.2 work?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@HolgerKnublauch mentioned it as a possibility.


The first 2 of these have been supported in [this xtext file](https://gitlab.com/allotrope-open-source/shape-editor/-/blob/master/src/com.osthus.shapes.shaclc.parent/com.osthus.shapes.shaclc/src/com/osthus/shapes/shaclc/SHACLC.xtext) by [allotrope](https://www.allotrope.org/). Some or all of these additions may be ignored in favour of keeping SHACL-C a simple syntax to implement and use.
A number of features from [SHACLC.xtext](https://gitlab.com/allotrope-open-source/shape-editor/-/blob/master/src/com.osthus.shapes.shaclc.parent/com.osthus.shapes.shaclc/src/com/osthus/shapes/shaclc/SHACLC.xtext) by [Allotrope](https://www.allotrope.org/):
- [Shape Libraries](https://rawgit2.com/VladimirAlexiev/shacl/shaclc-grammars/shacl-compact-syntax/grammar/shaclc-XText.html#ShaclDoc) (versioned). Packaging shapes into libraries enables modularized development of shapes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you please provide additional information or a pointer to describe what triples are produced when parsing this part of the grammar to make it clearer how the shape library works.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have no idea whether these are implemented. They are good material for extending the scope of SHACL 1.2. I'll make a separate issue.
Guess we should add a note which are part of SHACL, and which are speculative?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Guess we should add a note which are part of SHACL, and which are speculative?

That would be great :)

@VladimirAlexiev VladimirAlexiev Aug 11, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is used together with [Import](https://rawgit2.com/VladimirAlexiev/shacl/shaclc-grammars/shacl-compact-syntax/grammar/shaclc-XText.html#ImportsDecl).
A shape library is very similar to an OWL ontology and technically works in the same way.
In fact, we now use OWL ontologies because of inference from `owl:import`, but there was quite some discussion about whether the assembly of shapes is an ontology in the OWL sense.
For any large scale application of SHACL, it is necessary to modularize, and it felt like this was a serious gap in the specification.
- [Imports](https://rawgit2.com/VladimirAlexiev/shacl/shaclc-grammars/shacl-compact-syntax/grammar/shaclc-XText.html#ImportsDecl)
- Rich [Targets](https://rawgit2.com/VladimirAlexiev/shacl/shaclc-grammars/shacl-compact-syntax/grammar/shaclc-XText.html#Target) including SPARQL targets.
The inclusion of SPARQL resulted from implementation experience that expressiveness of SHACL alone was not enough for the Allotrope use case.
For example, we need to ensure the unique presence of some nodes in an Allotrope file, and use the SHACL SPARQL extension for it.
If we support SPARQL at all, it feels natural to also apply it to `SELECT` targets.
Allotrope uses SPARQL sparingly because it is "only" a SHACL extension, so from the view of many of the Allotrope members, not "official" enough.
- [Parameterized Targets](https://rawgit2.com/VladimirAlexiev/shacl/shaclc-grammars/shacl-compact-syntax/grammar/shaclc-XText.html#TargetShape)
- [Rules](https://rawgit2.com/VladimirAlexiev/shacl/shaclc-grammars/shacl-compact-syntax/grammar/shaclc-XText.html#RuleShape), but unlike SHACL-AF rules that have `subject, property, object` or SPARQL, [these rules use](https://rawgit2.com/VladimirAlexiev/shacl/shaclc-grammars/shacl-compact-syntax/grammar/shaclc-XText.html#RuleBody) `CONSTRUCT`, and have `IF` (being a shape to check) and `PRIORITY` parts
- [SPARQL Functions](https://rawgit2.com/VladimirAlexiev/shacl/shaclc-grammars/shacl-compact-syntax/grammar/shaclc-XText.html#FunctionShape), inspired by SPIN Functions
- Rich [Parameter Declarations](https://rawgit2.com/VladimirAlexiev/shacl/shaclc-grammars/shacl-compact-syntax/grammar/shaclc-XText.html#ParameterDeclaration) and respective assignments at invocation
- [Dedicated Syntax](https://rawgit2.com/VladimirAlexiev/shacl/shaclc-grammars/shacl-compact-syntax/grammar/shaclc-XText.html#SparqlConstraint) for SPARQL Constraints, i.e., you don't need to do `"""<sparql query>"""`.
- Having a syntax for SPARQL allows a much better integration.
- We do not have a language within a language.
- XText (and other grammar based code generators) can be used to directly generate code from it, and it is so much more powerful to have consistency ensured by a single parser.
- [Graphical Operators](https://rawgit2.com/VladimirAlexiev/shacl/shaclc-grammars/shacl-compact-syntax/grammar/shaclc-XText.html#OP_XONE) (e.g., `><`, `⊻`, and/or `⩒`) in addition to keywords (e.g., `xone` and/or `xor`).
This is a way to make SHACL-C even more compact, but many people cannot type them easily. The use of well-known operators can help make code more readable, and we expect that, like all models, they are far more often read then written, but where the boundary of obscurity ends is open to discussion.

Some or all of these additions may be ignored in favour of keeping SHACL-C a simple syntax to implement and use.

### [Making SHACL-C Lossless](https://github.com/w3c/shacl/issues/36)

There are attempts to implement lossless SHACL-C by allowing the use of a more Turtle-like syntax in places. We should align on a way of doing this and write it up in spec form. Existing attempts include:
- [Extended Compact Syntax in `shaclcjs`](https://github.com/jeswr/shaclcjs?tab=readme-ov-file#extended-shacl-compact-syntax)
- [make SHACL-C→SHACL nearly lossless TopQuadrant/shacl#98](https://github.com/TopQuadrant/shacl/issues/98) (escape into Turtle, and some extra links and ideas)

### Extending the test suite
## Extending the Test Suite

There is also work that can be done to make the test suite more robust such as:
- [SHACL-C: missing property shape TopQuadrant/shacl#142](https://github.com/TopQuadrant/shacl/issues/142) (test case)
- [SHACL-C→SHACL outputs `;` instead of `.` TopQuadrant/shacl#91](https://github.com/TopQuadrant/shacl/issues/91) (test case)
- [SHACL conversion: malformed lists TopQuadrant/shacl#92](https://github.com/TopQuadrant/shacl/issues/92) (test case)

## Implementations
The current SHACL-C implementations include
- https://jena.apache.org/documentation/shacl/#shacl-compact-syntax
- https://github.com/jeswr/shaclcjs and https://github.com/jeswr/shaclc-writer
- https://gitlab.com/allotrope-open-source/shape-editor
Current SHACL-C implementations include those listed below.

**Parsers/writers** (i.e., convertors between SHACL and SHACL-C)
- TopQuadrant had a SHACL-C implementation that was deprecated in favor of Jena's.
The the current SHACL-C specification [cites the grammar](https://w3c.github.io/shacl/shacl-compact-syntax/#grammar-section) of this implementation
- [Jena](https://jena.apache.org/documentation/shacl/#shacl-compact-syntax): implemented in Java
- [allotrope-open-source/shape-editor](https://gitlab.com/allotrope-open-source/shape-editor): implemented in Java for the Eclipse framework (uses XTEXT).
Introduces a number of number of new SHACL-C Constructs (see https://github.com/w3c/shacl/issues/52), reflected above.
- [jeswr/shaclcjs](https://github.com/jeswr/shaclcjs) and [jeswr/shaclc-writer](https://github.com/jeswr/shaclc-writer): implemented in JavaScript
- [edmondchuc/shaclc](https://github.com/edmondchuc/shaclc): implemented in Python, also has a [playground](https://edmondchuc.github.io/shaclc/)

**Editing helpers**
- [jeswr/shaclc-language-server](https://github.com/jeswr/shaclc-language-server): Language Server, implements IntelliSense-like features for modern IDEs like VS-Code
- [VladimirAlexiev/shaclc-mode](https://github.com/VladimirAlexiev/shaclc-mode): for Emacs, implements syntax checking and highlighting, jumping from reference to definition


## Related Issues
- [SHACL-compact-syntax #7](https://github.com/w3c/shacl/issues/7)
Expand Down