SPIN (W3C member submission) is an RDF vocabulary to embed SPARQL-based rules, constraints, functions and templates into semantic web models. It also includes a triple-based serialization of SPARQL which can be used to share the SPARQL queries of rules, constraints etc in a machine-friendly format. Among others, this syntax operates on true URI references and is therefore independent of prefix declarations, makes it easier to find and refactor the resources used in the query and supports various meta-operations on the structure of a query.
However, over the years I have collected overwhelming feedback that the SPIN RDF notation is an obstacle to wider adoption of SPIN. I have therefore made the SPIN syntax more flexible, so that SPIN files can more easily be edited in text files, and to reduce the implementation costs of SPIN engines. The change that I have made to the spec (which is now online) is very small: SPIN already had a property called sp:text that can be used to store a query string in the conventional textual representation of SPARQL. All I needed to change was that:
ex:Person
a rdfs:Class ;
rdfs:label "Person"^^xsd:string ;
rdfs:subClassOf owl:Thing ;
spin:rule
[ a sp:Construct ;
sp:text """
CONSTRUCT {
?this ex:grandParent ?grandParent .
}
WHERE {
?parent ex:child ?this .
?grandParent ex:child ?parent .
}"""
] .
ex:Parent
a rdfs:Class ;
rdfs:label "Parent"^^xsd:string ;
rdfs:subClassOf ex:Person ;
spin:constraint
[ a sp:Ask ;
sp:text """
# must be at least 18 years old
ASK WHERE {
?this ex:age ?age .
FILTER (?age < 18) .
}"""
] .