Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@asanchez75
Created September 1, 2018 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asanchez75/1dc1424753065b5fa7153963af6dd8b2 to your computer and use it in GitHub Desktop.
Save asanchez75/1dc1424753065b5fa7153963af6dd8b2 to your computer and use it in GitHub Desktop.
SPARQL
PREFIX shapes: <http://example.org/shapes#>
PREFIX spin: <http://spinrdf.org/spin#>
PREFIX sp: <http://spinrdf.org/sp#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
WITH <urn:spin:rule:geometry:lib>
INSERT {
shapes:Solid
rdf:type owl:Class;
rdfs:label "Solid class";
spin:rs1 [
a sp:Construct;
sp:text """
CONSTRUCT { ?this <http://example.org/shapes#area> ?area }
WHERE {
{
SELECT ?this (xsd:float(?height) * xsd:float(?width)) AS ?area
WHERE {
?this <http://example.org/shapes#width> ?width ;
<http://example.org/shapes#height> ?height .
}
}
}
"""
] ;
spin:rs2 [
a sp:Construct;
sp:text """
CONSTRUCT { ?this <http://example.org/shapes#volume> ?volume }
WHERE {
{
SELECT ?this (xsd:float(?height) * xsd:float(?area)) AS ?volume
WHERE {
?this <http://example.org/shapes#area> ?area ;
<http://example.org/shapes#height> ?height .
}
}
}
"""
] .
shapes:rs1 rdf:type rdf:Property.
shapes:rs2 rdf:type rdf:Property.
shapes:rs1 rdfs:subPropertyOf spin:rule .
shapes:rs2 rdfs:subPropertyOf spin:rule .
shapes:rs1 spin:nextRuleProperty shapes:rs2 .
shapes:rs2 spin:nextRuleProperty spin:rule .
} ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment