Every SHACL property shape is a collection of constraints — rules that the property's values must satisfy. RDF Studio's OWL-to-SHACL translator generates these constraints from your ontology. This article covers every constraint type with Northwind examples.
sh:datatype ensures a property's value has the correct XSD datatype:
sh:datatype
sh:property [ sh:path nwo:companyName ; sh:datatype xsd:string ; ] .
This rejects non-string values:
"Alfreds Futterkiste"^^xsd:string
42
<http://example.org/name>
xsd:string
sh:datatype xsd:string
xsd:integer
sh:datatype xsd:integer
xsd:decimal
sh:datatype xsd:decimal
xsd:date
sh:datatype xsd:date
xsd:boolean
sh:datatype xsd:boolean
xsd:anyURI
sh:datatype xsd:anyURI
xsd:gYear
sh:datatype xsd:gYear
sh:class ensures an object property points to an instance of the correct class:
sh:class
sh:property [ sh:path nwo:reportsTo ; sh:class nwo:Employee ; ] .
This validates that the value of reportsTo is typed as Employee:
reportsTo
Employee
nwr:employee-2
employee-2 a nwo:Employee
nwr:customer-1
customer-1 a nwo:Customer
sh:nodeKind constrains whether a value is a literal, a URI, or a blank node:
sh:nodeKind
# Datatype properties get sh:nodeKind sh:Literal sh:property [ sh:path nwo:firstName ; sh:datatype xsd:string ; sh:nodeKind sh:Literal ; # Must be a literal value ] . # Object properties use sh:class (nodeKind is implicit) sh:property [ sh:path nwo:reportsTo ; sh:class nwo:Employee ; # Must be a URI of type Employee ] .
RDF Studio automatically adds sh:nodeKind sh:Literal to all datatype property shapes. This prevents a subtle error where a URI is used where a literal string was expected:
sh:nodeKind sh:Literal
"Nancy"^^xsd:string
<http://example.org/Nancy>
These are the most common constraints. They control how many values a property must/can have.
sh:property [ sh:path nwo:firstName ; sh:minCount 1 ; # At least one value required ] .
sh:minCount 1
sh:minCount 0
sh:minCount 2
sh:property [ sh:path nwo:birthDate ; sh:maxCount 1 ; # At most one value allowed ] .
sh:maxCount 1
sh:property [ sh:path nwo:firstName ; sh:minCount 1 ; sh:maxCount 1 ; # Exactly one value required ] .
This is the strictest cardinality — the property must be present and must have exactly one value.
owl:FunctionalProperty
owl:cardinality N
sh:minCount N
sh:maxCount N
owl:minCardinality N
owl:maxCardinality N
# Employee firstName — required, single-valued nwo:firstName a owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:domain nwo:Employee . # → sh:maxCount 1 (from FunctionalProperty) # Order orderDetails —multi-valued (one order has many details) nwo:orderDetails a owl:ObjectProperty ; rdfs:domain nwo:Order ; rdfs:range nwo:OrderDetail . # → no sh:maxCount (multiple values allowed)
sh:pattern validates string values against a regular expression:
sh:pattern
sh:property [ sh:path nwo:postalCode ; sh:datatype xsd:string ; sh:pattern "^[0-9]{5}(-[0-9]{4})? RDF Studio – SPARQL Editor, Ontology Manager & Knowledge Graph Explorer RDF Studio is a free semantic web IDE and training platform for browsing, querying, and editing RDF knowledge graphs. Home of the Northwind RDF use case with 80+ executable SPARQL competency questions (use case stories) and query templates. Key Features Northwind RDF Use Case – A curated training dataset with full OWL ontology, sample data, and 80+ executable SPARQL competency questions with business use case stories following EKGF methodology. Query Library – 80+ categorized queries spanning data exploration, CRUD operations, OWL axioms, taxonomy navigation, federated queries, and graph analytics — each with descriptions and use case context. Query Templates – Reusable SPARQL patterns for basic exploration, data quality checks, and graph analytics that work across any dataset. SPARQL Editor – Full SPARQL 1.1 query editor with syntax highlighting, autocomplete, PREFIX folding, query library, and execution history. Visual Ontology Editor – Create and edit OWL/RDFS classes, properties, and restrictions in an interactive graph editor with draft workflow and layout persistence. SHACL Shapes Editor & Validator – Browse, edit, auto-generate, and validate SHACL shapes with a validation dashboard and maturity scoring. Knowledge Graph Visualization – Interactive graph visualization with multiple layout engines, node expansion, search, and export. Faceted Search – Auto-generated faceted search interfaces from RDF/OWL ontologies with filters, sorting, and pagination. Traversal Query Builder – Cross-class query builder for navigating complex knowledge graph relationships. Taxonomy & Vocabulary Management – SKOS taxonomy browser, vocabulary import (FOAF, Dublin Core, RDFS), and hierarchical tree editing. Multi-Database Support – Connect to external SPARQL endpoints (GraphDB, Virtuoso, Stardog, Neptune, Fuseki). RDF Instance CRUD – Create, read, update, and delete RDF instances with SHACL validation and named graph targeting. Ontology Maturity Scoring – 5-dimension assessment of ontology quality with schema-data drift detection. Supported Standards RDF, RDFS, OWL, OWL 2, SPARQL 1.1, SHACL, SKOS, Turtle, N-Triples, JSON-LD, Dublin Core, FOAF, Schema.org Supported Triple Stores Oxigraph, GraphDB, Virtuoso, Stardog, Amazon Neptune, Apache Jena Fuseki, and any SPARQL 1.1 compatible endpoint. Technology Built with Python, React, and TypeScript. Created by M Barbieri quot; ; # US ZIP code format ] .
RDF Studio is a free semantic web IDE and training platform for browsing, querying, and editing RDF knowledge graphs. Home of the Northwind RDF use case with 80+ executable SPARQL competency questions (use case stories) and query templates.
RDF, RDFS, OWL, OWL 2, SPARQL 1.1, SHACL, SKOS, Turtle, N-Triples, JSON-LD, Dublin Core, FOAF, Schema.org
Oxigraph, GraphDB, Virtuoso, Stardog, Amazon Neptune, Apache Jena Fuseki, and any SPARQL 1.1 compatible endpoint.
Built with Python, React, and TypeScript.
Created by M Barbieri
This catches malformed values:
"98101"
"98101-1234"
"ABC"
"9810"
The translator extracts patterns from OWL datatype restrictions using xsd:pattern:
xsd:pattern
# OWL input nwo:postalCode rdfs:range [ a rdfs:Datatype ; owl:onDatatype xsd:string ; owl:withRestrictions ( [ xsd:pattern "^[0-9]{5} RDF Studio – SPARQL Editor, Ontology Manager & Knowledge Graph Explorer RDF Studio is a free semantic web IDE and training platform for browsing, querying, and editing RDF knowledge graphs. Home of the Northwind RDF use case with 80+ executable SPARQL competency questions (use case stories) and query templates. Key Features Northwind RDF Use Case – A curated training dataset with full OWL ontology, sample data, and 80+ executable SPARQL competency questions with business use case stories following EKGF methodology. Query Library – 80+ categorized queries spanning data exploration, CRUD operations, OWL axioms, taxonomy navigation, federated queries, and graph analytics — each with descriptions and use case context. Query Templates – Reusable SPARQL patterns for basic exploration, data quality checks, and graph analytics that work across any dataset. SPARQL Editor – Full SPARQL 1.1 query editor with syntax highlighting, autocomplete, PREFIX folding, query library, and execution history. Visual Ontology Editor – Create and edit OWL/RDFS classes, properties, and restrictions in an interactive graph editor with draft workflow and layout persistence. SHACL Shapes Editor & Validator – Browse, edit, auto-generate, and validate SHACL shapes with a validation dashboard and maturity scoring. Knowledge Graph Visualization – Interactive graph visualization with multiple layout engines, node expansion, search, and export. Faceted Search – Auto-generated faceted search interfaces from RDF/OWL ontologies with filters, sorting, and pagination. Traversal Query Builder – Cross-class query builder for navigating complex knowledge graph relationships. Taxonomy & Vocabulary Management – SKOS taxonomy browser, vocabulary import (FOAF, Dublin Core, RDFS), and hierarchical tree editing. Multi-Database Support – Connect to external SPARQL endpoints (GraphDB, Virtuoso, Stardog, Neptune, Fuseki). RDF Instance CRUD – Create, read, update, and delete RDF instances with SHACL validation and named graph targeting. Ontology Maturity Scoring – 5-dimension assessment of ontology quality with schema-data drift detection. Supported Standards RDF, RDFS, OWL, OWL 2, SPARQL 1.1, SHACL, SKOS, Turtle, N-Triples, JSON-LD, Dublin Core, FOAF, Schema.org Supported Triple Stores Oxigraph, GraphDB, Virtuoso, Stardog, Amazon Neptune, Apache Jena Fuseki, and any SPARQL 1.1 compatible endpoint. Technology Built with Python, React, and TypeScript. Created by M Barbieri quot; ] ) ] . # SHACL output sh:property [ sh:path nwo:postalCode ; sh:pattern "^[0-9]{5} RDF Studio – SPARQL Editor, Ontology Manager & Knowledge Graph Explorer RDF Studio is a free semantic web IDE and training platform for browsing, querying, and editing RDF knowledge graphs. Home of the Northwind RDF use case with 80+ executable SPARQL competency questions (use case stories) and query templates. Key Features Northwind RDF Use Case – A curated training dataset with full OWL ontology, sample data, and 80+ executable SPARQL competency questions with business use case stories following EKGF methodology. Query Library – 80+ categorized queries spanning data exploration, CRUD operations, OWL axioms, taxonomy navigation, federated queries, and graph analytics — each with descriptions and use case context. Query Templates – Reusable SPARQL patterns for basic exploration, data quality checks, and graph analytics that work across any dataset. SPARQL Editor – Full SPARQL 1.1 query editor with syntax highlighting, autocomplete, PREFIX folding, query library, and execution history. Visual Ontology Editor – Create and edit OWL/RDFS classes, properties, and restrictions in an interactive graph editor with draft workflow and layout persistence. SHACL Shapes Editor & Validator – Browse, edit, auto-generate, and validate SHACL shapes with a validation dashboard and maturity scoring. Knowledge Graph Visualization – Interactive graph visualization with multiple layout engines, node expansion, search, and export. Faceted Search – Auto-generated faceted search interfaces from RDF/OWL ontologies with filters, sorting, and pagination. Traversal Query Builder – Cross-class query builder for navigating complex knowledge graph relationships. Taxonomy & Vocabulary Management – SKOS taxonomy browser, vocabulary import (FOAF, Dublin Core, RDFS), and hierarchical tree editing. Multi-Database Support – Connect to external SPARQL endpoints (GraphDB, Virtuoso, Stardog, Neptune, Fuseki). RDF Instance CRUD – Create, read, update, and delete RDF instances with SHACL validation and named graph targeting. Ontology Maturity Scoring – 5-dimension assessment of ontology quality with schema-data drift detection. Supported Standards RDF, RDFS, OWL, OWL 2, SPARQL 1.1, SHACL, SKOS, Turtle, N-Triples, JSON-LD, Dublin Core, FOAF, Schema.org Supported Triple Stores Oxigraph, GraphDB, Virtuoso, Stardog, Amazon Neptune, Apache Jena Fuseki, and any SPARQL 1.1 compatible endpoint. Technology Built with Python, React, and TypeScript. Created by M Barbieri quot; ; ] .
Patterns are powerful for enforcing data formats: phone numbers, postal codes, email formats, identifier patterns, etc.
sh:order controls the display order of properties in the SHACL UI:
sh:order
sh:property [ sh:path nwo:firstName ; sh:order 0 ; # Displayed first ] ; sh:property [ sh:path nwo:lastName ; sh:order 1 ; # Displayed second ] ; sh:property [ sh:path nwo:title ; sh:order 2 ; # Displayed third ] .
Without sh:order, properties appear in whatever order the RDF parser encounters them — which can be random. With sh:order, you get a predictable, logical layout:
RDF Studio's SHACL UI sorts property shapes by sh:order value (ascending). Properties without an order value appear at the end. The translator assigns order values based on the property's position in the ontology file, so the ontology author's intended layout is preserved.
sh:description carries documentation from the ontology into the shape:
sh:description
sh:property [ sh:path nwo:unitPrice ; sh:datatype xsd:decimal ; sh:description "The price per unit of the product" ; ] .
This comes from rdfs:comment on the OWL property:
rdfs:comment
# OWL input nwo:unitPrice a owl:DatatypeProperty ; rdfs:comment "The price per unit of the product" . # SHACL output sh:property [ sh:path nwo:unitPrice ; sh:description "The price per unit of the product" ; ] .
Descriptions are displayed in the SHACL UI to help users understand what each constraint means without referring back to the ontology.
Property shapes can combine multiple constraints. Here's a fully-specified property:
sh:property [ sh:path nwo:unitPrice ; sh:name "unit price" ; sh:description "The price per unit of the product" ; sh:datatype xsd:decimal ; sh:nodeKind sh:Literal ; sh:minCount 1 ; # Required sh:maxCount 1 ; # Single-valued sh:minExclusive 0 ; # Must be positive sh:order 3 ; # Display position ] .
This single property shape enforces:
rdfs:range
nwo:Employee
owl:DatatypeProperty
sh:Literal
sh:minCount
owl:minCardinality
1
sh:maxCount
"^[0-9]+ RDF Studio – SPARQL Editor, Ontology Manager & Knowledge Graph Explorer RDF Studio is a free semantic web IDE and training platform for browsing, querying, and editing RDF knowledge graphs. Home of the Northwind RDF use case with 80+ executable SPARQL competency questions (use case stories) and query templates. Key Features Northwind RDF Use Case – A curated training dataset with full OWL ontology, sample data, and 80+ executable SPARQL competency questions with business use case stories following EKGF methodology. Query Library – 80+ categorized queries spanning data exploration, CRUD operations, OWL axioms, taxonomy navigation, federated queries, and graph analytics — each with descriptions and use case context. Query Templates – Reusable SPARQL patterns for basic exploration, data quality checks, and graph analytics that work across any dataset. SPARQL Editor – Full SPARQL 1.1 query editor with syntax highlighting, autocomplete, PREFIX folding, query library, and execution history. Visual Ontology Editor – Create and edit OWL/RDFS classes, properties, and restrictions in an interactive graph editor with draft workflow and layout persistence. SHACL Shapes Editor & Validator – Browse, edit, auto-generate, and validate SHACL shapes with a validation dashboard and maturity scoring. Knowledge Graph Visualization – Interactive graph visualization with multiple layout engines, node expansion, search, and export. Faceted Search – Auto-generated faceted search interfaces from RDF/OWL ontologies with filters, sorting, and pagination. Traversal Query Builder – Cross-class query builder for navigating complex knowledge graph relationships. Taxonomy & Vocabulary Management – SKOS taxonomy browser, vocabulary import (FOAF, Dublin Core, RDFS), and hierarchical tree editing. Multi-Database Support – Connect to external SPARQL endpoints (GraphDB, Virtuoso, Stardog, Neptune, Fuseki). RDF Instance CRUD – Create, read, update, and delete RDF instances with SHACL validation and named graph targeting. Ontology Maturity Scoring – 5-dimension assessment of ontology quality with schema-data drift detection. Supported Standards RDF, RDFS, OWL, OWL 2, SPARQL 1.1, SHACL, SKOS, Turtle, N-Triples, JSON-LD, Dublin Core, FOAF, Schema.org Supported Triple Stores Oxigraph, GraphDB, Virtuoso, Stardog, Amazon Neptune, Apache Jena Fuseki, and any SPARQL 1.1 compatible endpoint. Technology Built with Python, React, and TypeScript. Created by M Barbieri quot;
0
2
"The name..."
sh:name
rdfs:label
"first name"