SlideShare a Scribd company logo
SPIN and Shapes 
RDF Data Shapes WG F2F, Nov 2014 
Holger Knublauch 
TopQuadrant, Inc.
SPIN History and Status 
• Created at TopQuadrant 2008 
• Addresses requirements from customer projects 
• Supported by TopBraid tools (incl. TBC Free) 
• Open source: http://topbraid.org/spin/api/ 
• Partial support by 3rd party database vendors 
• W3C Member Submission 2011 
• Many SPIN-based systems are in production
Constraints in SPARQL (ASK) 
ss:Square 
spin:constraint [ 
a sp:Ask ; 
sp:text """ 
# Width and height must be equal 
ASK WHERE { 
?this ss:width ?width . 
?this ss:height ?height . 
FILTER (?width != ?height) . 
} 
""" 
]
Constraints in SPARQL (CONSTRUCT) 
ss:Square 
spin:constraint [ 
rdf:type sp:Construct ; 
sp:text """ 
# Width and height must be equal 
CONSTRUCT { 
_:cv a spin:ConstraintViolation ; 
spin:violationRoot ?this ; 
spin:violationPath ss:height ; 
rdfs:label "Width and height must be equal" 
} 
WHERE { 
?this ss:width ?width . 
?this ss:height ?height . 
FILTER (?width != ?height) . 
} 
""" 
]
Possible Syntactic Sugar 
Idea from Simister, Brickley: 
http://www.w3.org/2001/sw/wiki/images/0/00/SimpleApplication- 
SpecificConstraintsforRDFModels.pdf 
ss:Square 
spin:constraint [ 
a spin:Ask ; 
spin:context ss:height ; 
spin:message "Width and height must be equal" ; 
spin:sparql """ 
ASK WHERE { 
?this ss:width ?width . 
?this ss:height ?height . 
FILTER (?width != ?height) . 
} 
""" 
] 
(The current SPIN is just a starting point, it’s an open RDF vocabulary)
Alternative to source code editing 
Syntax checking 
Auto-complete 
Keyword highlighting 
Results preview …
Positive values constraint in SPARQL 
ss:Rectangle 
spin:constraint [ 
a sp:Construct ; 
sp:text """ 
# The value of ss:width must be > 0 
CONSTRUCT { 
_:cv a spin:ConstraintViolation ; 
spin:violationRoot ?this ; 
spin:violationPath ss:width ; 
rdfs:label "The width of a rectangle must be > 0" 
} 
WHERE { 
?this ss:width ?width . 
FILTER (?width <= 0) . 
} 
""" 
] 
… the same would have to be repeated for ss:height
Generalizing the constraint 
ss:Rectangle 
spin:constraint [ 
a sp:Construct ; 
sp:text """ 
# The value of ss:width must be > 0 
CONSTRUCT { 
_:cv a spin:ConstraintViolation ; 
spin:violationRoot ?this ; 
spin:violationPath ss:width ; 
rdfs:label "The width of a rectangle must be > 0" 
} 
WHERE { 
?this ss:width ?width . 
FILTER (?width <= 0) . 
} 
""" 
] 
ss:width could be 
replaced with any 
property, e.g. 
ss:height
Introducing a SPIN Template 
ss:PositivePropertyValueConstraint a spin:ConstructTemplate ; 
spin:constraint [ a spl:Argument 
spl:predicate arg:property ; 
spl:valueType rdf:Property ; 
rdfs:comment "The property to constrain (e.g. ss:width)" 
] ; 
spin:body [ a sp:Construct ; 
sp:text """ 
CONSTRUCT { 
_:cv a spin:ConstraintViolation ; 
spin:violationRoot ?this ; 
spin:violationPath ?property ; 
rdfs:label "Positive value expected" 
} 
WHERE { 
?this ?property ?value . 
FILTER (?value <= 0) . 
} 
""" 
] ;
Using a SPIN Template 
ss:Rectangle 
spin:constraint [ 
a ss:PositivePropertyValueConstraint ; 
arg:property ss:height ; 
] ; 
spin:constraint [ 
a ss:PositivePropertyValueConstraint ; 
arg:property ss:width ; 
] . 
Such templates can be published in libraries, for example for Shapes.
Example Tool Support (1)
Example Tool Support (2)
Example Tool Support (3)
SPIN Templates 
• Can define new modeling languages 
• Template definitions are linked data (URI etc) 
• Encapsulate/hide SPARQL queries 
• Yet executable on standard RDF databases 
• But processors do not have to use SPARQL only 
• Combine maximum flexibility & expressivity 
with a structural user-friendly syntax.
SPIN Functions
SPIN Libraries 
• SPIN templates, functions and constraints can 
be published on the semantic web 
– Example: http://semwebquality.org 
• Libraries define “Profiles” 
• Web provides a natural evolution mechanism 
• This WG would define a standard library
Possible Shapes Architecture
OSLC Bug Example 
oslc_cm:ChangeRequest 
a rdfs:Class ; 
rdfs:label "Change request" ; 
oslc:property [ 
ChangeRequest 
title : string [1..1] 
status : status-values [0..1] 
a oslc:Property ; 
oslc:propertyDefinition dcterms:title ; 
oslc:occurs oslc:Exactly-one 
] ; 
oslc:property [ 
a oslc:Property ; 
oslc:propertyDefinition oslc_cm:status ; 
oslc:allowedValues oslc_cm:status-values ; 
oslc:occurs oslc:Zero-or-one 
] . 
This is a valid SPIN document

More Related Content

PPTX
SHACL Specification Draft
PPTX
SPIN in Five Slides
PPTX
RDF SHACL, Annotations, and Data Frames
PPTX
ElasticSearch AJUG 2013
PDF
Elasticsearch Basics
PDF
Introduction to Elasticsearch
ODP
Cool bonsai cool - an introduction to ElasticSearch
PDF
Polyglot persistence
SHACL Specification Draft
SPIN in Five Slides
RDF SHACL, Annotations, and Data Frames
ElasticSearch AJUG 2013
Elasticsearch Basics
Introduction to Elasticsearch
Cool bonsai cool - an introduction to ElasticSearch
Polyglot persistence

What's hot (20)

PDF
Gerry McNicol Graph Databases
PDF
Simple search with elastic search
PPTX
Solid pods and the future of the spatial web
PPTX
Elastic Search
PDF
Your Data, Your Search, ElasticSearch (EURUKO 2011)
PDF
Elasticsearch And Ruby [RuPy2012]
PDF
Analytics and Graph Traversal with Solr - Yonik Seeley, Cloudera
PDF
Elasticsearch (Rubyshift 2013)
PPTX
Beyond shuffling - Strata London 2016
PPTX
Aem sling resolution
PPTX
Elastic search Walkthrough
PPTX
Solr vs. Elasticsearch - Case by Case
PDF
A Survey of Elasticsearch Usage
PPT
Finding knowledge, data and answers on the Semantic Web
PDF
Elasticsearch in 15 Minutes
PPTX
An Introduction to Elastic Search.
PDF
Json the-x-in-ajax1588
PDF
Using Sphinx for Search in PHP
PDF
Introduction to Elasticsearch
PPTX
How to scale relational (OLTP) databases. Think: Sharding @C16LV
Gerry McNicol Graph Databases
Simple search with elastic search
Solid pods and the future of the spatial web
Elastic Search
Your Data, Your Search, ElasticSearch (EURUKO 2011)
Elasticsearch And Ruby [RuPy2012]
Analytics and Graph Traversal with Solr - Yonik Seeley, Cloudera
Elasticsearch (Rubyshift 2013)
Beyond shuffling - Strata London 2016
Aem sling resolution
Elastic search Walkthrough
Solr vs. Elasticsearch - Case by Case
A Survey of Elasticsearch Usage
Finding knowledge, data and answers on the Semantic Web
Elasticsearch in 15 Minutes
An Introduction to Elastic Search.
Json the-x-in-ajax1588
Using Sphinx for Search in PHP
Introduction to Elasticsearch
How to scale relational (OLTP) databases. Think: Sharding @C16LV
Ad

Similar to SPIN and Shapes (20)

PPTX
2015.09 - Guidance, Please! Towards a Framework for RDF-Based Constraint Lang...
PPTX
Guidance, Please! Towards a Framework for RDF-based Constraint Languages.
PPTX
2015.03 - The RDF Validator - A Tool to Validate RDF Data (KIM)
PDF
RDF Seminar Presentation
PPT
Re-using Media on the Web: Media fragment re-mixing and playout
PPTX
Validating and Describing Linked Data Portals using RDF Shape Expressions
PPTX
A Little SPARQL in your Analytics
PDF
Knowledge Engineering: Semantic web, web of data, linked data
PDF
Semantic web assignment 2
PPTX
SHACL: Shaping the Big Ball of Data Mud
PDF
Transforming Your Data with GraphDB: GraphDB Fundamentals, Jan 2018
PDF
Federation and Navigation in SPARQL 1.1
PDF
W3C Data Shapes Working Group 2014
PPTX
What;s Coming In SPARQL2?
PDF
A Generic Mapping-based Query Translation from SPARQL to Various Target Datab...
PPTX
Introduction to dotNetRDF
PDF
8th TUC Meeting - Peter Boncz (CWI). Query Language Task Force status
PDF
Optimizing SPARQL Queries with SHACL.pdf
PPTX
LiveLinkedData - TransWebData - Nantes 2013
PDF
ESWC 2013 Poster: Representing and Querying Negative Knowledge in RDF
2015.09 - Guidance, Please! Towards a Framework for RDF-Based Constraint Lang...
Guidance, Please! Towards a Framework for RDF-based Constraint Languages.
2015.03 - The RDF Validator - A Tool to Validate RDF Data (KIM)
RDF Seminar Presentation
Re-using Media on the Web: Media fragment re-mixing and playout
Validating and Describing Linked Data Portals using RDF Shape Expressions
A Little SPARQL in your Analytics
Knowledge Engineering: Semantic web, web of data, linked data
Semantic web assignment 2
SHACL: Shaping the Big Ball of Data Mud
Transforming Your Data with GraphDB: GraphDB Fundamentals, Jan 2018
Federation and Navigation in SPARQL 1.1
W3C Data Shapes Working Group 2014
What;s Coming In SPARQL2?
A Generic Mapping-based Query Translation from SPARQL to Various Target Datab...
Introduction to dotNetRDF
8th TUC Meeting - Peter Boncz (CWI). Query Language Task Force status
Optimizing SPARQL Queries with SHACL.pdf
LiveLinkedData - TransWebData - Nantes 2013
ESWC 2013 Poster: Representing and Querying Negative Knowledge in RDF
Ad

Recently uploaded (20)

PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
history of c programming in notes for students .pptx
PPTX
ai tools demonstartion for schools and inter college
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
System and Network Administration Chapter 2
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
System and Network Administraation Chapter 3
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Online Work Permit System for Fast Permit Processing
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
medical staffing services at VALiNTRY
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PPTX
Introduction to Artificial Intelligence
PDF
AI in Product Development-omnex systems
Understanding Forklifts - TECH EHS Solution
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
history of c programming in notes for students .pptx
ai tools demonstartion for schools and inter college
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
System and Network Administration Chapter 2
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Upgrade and Innovation Strategies for SAP ERP Customers
System and Network Administraation Chapter 3
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Online Work Permit System for Fast Permit Processing
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Design an Analysis of Algorithms II-SECS-1021-03
medical staffing services at VALiNTRY
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PTS Company Brochure 2025 (1).pdf.......
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Introduction to Artificial Intelligence
AI in Product Development-omnex systems

SPIN and Shapes

  • 1. SPIN and Shapes RDF Data Shapes WG F2F, Nov 2014 Holger Knublauch TopQuadrant, Inc.
  • 2. SPIN History and Status • Created at TopQuadrant 2008 • Addresses requirements from customer projects • Supported by TopBraid tools (incl. TBC Free) • Open source: http://topbraid.org/spin/api/ • Partial support by 3rd party database vendors • W3C Member Submission 2011 • Many SPIN-based systems are in production
  • 3. Constraints in SPARQL (ASK) ss:Square spin:constraint [ a sp:Ask ; sp:text """ # Width and height must be equal ASK WHERE { ?this ss:width ?width . ?this ss:height ?height . FILTER (?width != ?height) . } """ ]
  • 4. Constraints in SPARQL (CONSTRUCT) ss:Square spin:constraint [ rdf:type sp:Construct ; sp:text """ # Width and height must be equal CONSTRUCT { _:cv a spin:ConstraintViolation ; spin:violationRoot ?this ; spin:violationPath ss:height ; rdfs:label "Width and height must be equal" } WHERE { ?this ss:width ?width . ?this ss:height ?height . FILTER (?width != ?height) . } """ ]
  • 5. Possible Syntactic Sugar Idea from Simister, Brickley: http://www.w3.org/2001/sw/wiki/images/0/00/SimpleApplication- SpecificConstraintsforRDFModels.pdf ss:Square spin:constraint [ a spin:Ask ; spin:context ss:height ; spin:message "Width and height must be equal" ; spin:sparql """ ASK WHERE { ?this ss:width ?width . ?this ss:height ?height . FILTER (?width != ?height) . } """ ] (The current SPIN is just a starting point, it’s an open RDF vocabulary)
  • 6. Alternative to source code editing Syntax checking Auto-complete Keyword highlighting Results preview …
  • 7. Positive values constraint in SPARQL ss:Rectangle spin:constraint [ a sp:Construct ; sp:text """ # The value of ss:width must be > 0 CONSTRUCT { _:cv a spin:ConstraintViolation ; spin:violationRoot ?this ; spin:violationPath ss:width ; rdfs:label "The width of a rectangle must be > 0" } WHERE { ?this ss:width ?width . FILTER (?width <= 0) . } """ ] … the same would have to be repeated for ss:height
  • 8. Generalizing the constraint ss:Rectangle spin:constraint [ a sp:Construct ; sp:text """ # The value of ss:width must be > 0 CONSTRUCT { _:cv a spin:ConstraintViolation ; spin:violationRoot ?this ; spin:violationPath ss:width ; rdfs:label "The width of a rectangle must be > 0" } WHERE { ?this ss:width ?width . FILTER (?width <= 0) . } """ ] ss:width could be replaced with any property, e.g. ss:height
  • 9. Introducing a SPIN Template ss:PositivePropertyValueConstraint a spin:ConstructTemplate ; spin:constraint [ a spl:Argument spl:predicate arg:property ; spl:valueType rdf:Property ; rdfs:comment "The property to constrain (e.g. ss:width)" ] ; spin:body [ a sp:Construct ; sp:text """ CONSTRUCT { _:cv a spin:ConstraintViolation ; spin:violationRoot ?this ; spin:violationPath ?property ; rdfs:label "Positive value expected" } WHERE { ?this ?property ?value . FILTER (?value <= 0) . } """ ] ;
  • 10. Using a SPIN Template ss:Rectangle spin:constraint [ a ss:PositivePropertyValueConstraint ; arg:property ss:height ; ] ; spin:constraint [ a ss:PositivePropertyValueConstraint ; arg:property ss:width ; ] . Such templates can be published in libraries, for example for Shapes.
  • 14. SPIN Templates • Can define new modeling languages • Template definitions are linked data (URI etc) • Encapsulate/hide SPARQL queries • Yet executable on standard RDF databases • But processors do not have to use SPARQL only • Combine maximum flexibility & expressivity with a structural user-friendly syntax.
  • 16. SPIN Libraries • SPIN templates, functions and constraints can be published on the semantic web – Example: http://semwebquality.org • Libraries define “Profiles” • Web provides a natural evolution mechanism • This WG would define a standard library
  • 18. OSLC Bug Example oslc_cm:ChangeRequest a rdfs:Class ; rdfs:label "Change request" ; oslc:property [ ChangeRequest title : string [1..1] status : status-values [0..1] a oslc:Property ; oslc:propertyDefinition dcterms:title ; oslc:occurs oslc:Exactly-one ] ; oslc:property [ a oslc:Property ; oslc:propertyDefinition oslc_cm:status ; oslc:allowedValues oslc_cm:status-values ; oslc:occurs oslc:Zero-or-one ] . This is a valid SPIN document