Re: Draft: SPIN Minimum Profile

Hi Karen,

if Resource Shapes are the "language" then SPIN itself is mostly a 
"meta-language". I am not sure how this relates to the requirements 
database - at least those topics would need to be kept apart.

In terms of other specific "Shape-like" requirements, you may want to 
take a look at this SPIN library:

http://semwebquality.org/mediawiki/index.php?title=SemWebQuality.org

which includes numerous SPIN templates for common patterns.

In terms of the core SPIN templates that we have always used, there are 
just two important ones:

spl:Attribute
     - spl:predicate
     - spl:valueType
     - spl:minCount
     - spl:maxCount
     - spl:defaultValue

spl:Argument
     - spl:predicate
     - spl:valueType
     - spl:optional (false is default, meaning cardinality [1..1])
     - spl:defaultValue

Rather recently, for our EVN product, we have introduced a few more, 
which you can see if you download TBC-FE and open spl.spin.ttl, then 
look under spl:ConstraintTemplates



But I am sure this is just the start and we are not "married" to those 
particular definitions. Excerpts from the documentation (auto-generated 
using SPARQL Web Pages) is below.

HTH
Holger


    spl:Argument (spin:ConstructTemplate)

Provides metadata about an argument of a SPIN Function or Template. 
Arguments wrap a given rdf:Property (predicate) and specify its value 
type and whether the argument is optional. When used as spin:constraing, 
the body of this template will verify that a non-optional value exists 
and that it has the specified value type.


      Arguments

*rdfs:comment* (xsd:string): [Optional] a comment describing the argument
*spl:defaultValue*: [Optional] the default value for the argument
*spl:optional* (xsd:boolean): [Optional] indicates whether the argument 
is optional
*spl:predicate* (rdf:Property): the property holding the values of each 
function call
*spl:valueType* (rdfs:Class): [Optional] the value type of the argument


      Template body

CONSTRUCT {
     _:b0 a spin:ConstraintViolation .
     _:b0 spin:violationRoot ?this .
     _:b0 spin:violationPath ?predicate .
     _:b0 rdfs:label ?label .
}
WHERE {
     {
         FILTER isIRI(?this) .
     } .
     {
         {
             {
                 FILTER ((!bound(?optional)) || (?optional = false)) .
             } .
             OPTIONAL {
                 ?this ?predicate ?value .
             } .
             FILTER (!bound(?value)) .
         } .
         BIND (CONCAT("Missing value for argument ", afn:localname(?predicate)) AS ?label) .
     }
     UNION
     {
         {
             {
                 FILTER bound(?valueType) .
             } .
             ?this ?predicate ?value .
             FILTER ((!spl:instanceOf(?value, ?valueType)) && ((?valueType != rdfs:Resource) || isLiteral(?value))) .
         } .
         BIND (CONCAT("Incorrect type of argument ", afn:localname(?predicate), " (expected: ", afn:localname(?valueType), ")") AS ?label) .
     } .
}

------------------------------------------------------------------------


    spl:Attribute (spin:ConstructTemplate)

Defines an "attribute" of a class. Attribute definitions bundle common 
modeling patterns known from object-oriented languages like UML. Each 
attribute can have min and max cardinality, a value type and a default 
value. The attribute links a class with one RDF property. This template 
should be used as spin:constraints on a class to make sure that classes 
meet the expected cardinalities and valueType constraints. If a model 
wants to use spl:defaultValue, then it should instantiate the 
spl:ConstructDefaultValues as a spin:constructor at some root class, 
such as rdfs:Resource.


      Arguments

*rdfs:comment* (xsd:string): [Optional] a comment describing the meaning 
of this attribute
*spl:defaultValue*: [Optional] the default value of the attribute
*spl:maxCount* (xsd:integer): [Optional] the maximum number of values 
permitted for the property
*spl:minCount* (xsd:integer): [Optional] the minimum number of values 
permitted for the property
*spl:predicate* (rdf:Property): the RDF property holding the attribute value
*spl:valueType* (rdfs:Class): [Optional] the type that all values of the 
property must have


      Template body

CONSTRUCT {
     _:b0 a spin:ConstraintViolation .
     _:b0 spin:violationRoot ?this .
     _:b0 spin:violationPath ?predicate .
}
WHERE {
     {
         FILTER (bound(?minCount) && (spl:objectCount(?this, ?predicate) < ?minCount)) .
     }
     UNION
     {
         FILTER (bound(?maxCount) && (spl:objectCount(?this, ?predicate) > ?maxCount)) .
     }
     UNION
     {
         FILTER bound(?valueType) .
         ?this ?predicate ?value .
         FILTER (!spl:instanceOf(?value, ?valueType)) .
     } .
}

------------------------------------------------------------------------


    spl:ExistencePropertyPairConstraint (spl:ConstraintTemplate)


      Arguments

*arg:otherProperty* (rdf:Property): The "other" property.
*arg:property* (rdf:Property): The property being constrained.


      Template body

CONSTRUCT {
     _:b0 a spin:ConstraintViolation .
     _:b0 spin:violationRoot ?this .
     _:b0 spin:violationPath ?property .
     _:b0 rdfs:label ?message .
}
WHERE {
     FILTER EXISTS {
         ?this ?otherProperty ?someValue .
     } .
     FILTER NOT EXISTS {
         ?this ?property ?object .
     } .
     BIND (CONCAT("Property must have a value because ", ?otherProperty, " has") AS ?message) .
}

------------------------------------------------------------------------


    spl:NonExistencePropertyPairConstraint (spl:ConstraintTemplate)


      Arguments

*arg:otherProperty* (rdf:Property): The "other" property.
*arg:property* (rdf:Property): The property being constrained.


      Template body

CONSTRUCT {
     _:b0 a spin:ConstraintViolation .
     _:b0 spin:violationRoot ?this .
     _:b0 spin:violationPath ?property .
     _:b0 rdfs:label ?message .
}
WHERE {
     FILTER NOT EXISTS {
         ?this ?otherProperty ?someValue .
     } .
     FILTER EXISTS {
         ?this ?property ?object .
     } .
     BIND (CONCAT("Property must have no values because ", ?otherProperty, " has none") AS ?message) .
}

------------------------------------------------------------------------


    spl:ObjectCountPropertyConstraint (spl:ConstraintTemplate)

Represents a constraint that can be attached to a class to specify that 
a given property must have between min and max values.


      Arguments

*arg:maxCount* (xsd:integer): [Optional] The maximum number of values 
that the property must have.
*arg:minCount* (xsd:integer): [Optional] The minimum number of values 
that the property must have.
*arg:property* (rdf:Property): The property being constrained.


      Template body

CONSTRUCT {
     _:b0 a spin:ConstraintViolation .
     _:b0 spin:violationRoot ?this .
     _:b0 spin:violationPath ?property .
     _:b0 rdfs:label ?message .
}
WHERE {
     BIND (spl:objectCount(?this, ?property) AS ?objectCount) .
     FILTER ((bound(?minCount) && (?objectCount < ?minCount)) || (bound(?maxCount) && (?objectCount > ?maxCount))) .
     BIND (CONCAT("Invalid number of values: ", ?objectCount) AS ?message) .
}

------------------------------------------------------------------------


    spl:RegexPropertyConstraint (spl:ConstraintTemplate)


      Arguments

*arg:pattern* (xsd:string): The regular expression to match.
*arg:property* (rdf:Property): The property being constrained.


      Template body

CONSTRUCT {
     _:b0 a spin:ConstraintViolation .
     _:b0 spin:violationRoot ?this .
     _:b0 spin:violationPath ?property .
     _:b0 rdfs:label ?message .
}
WHERE {
     ?this ?property ?object .
     FILTER (!regex(xsd:string(?object), ?pattern)) .
     BIND (CONCAT("Value ", ?object, " must match the regular expression \"", ?pattern, "\"") AS ?message) .
}

------------------------------------------------------------------------


    spl:UntypedObjectPropertyConstraint (spl:ConstraintTemplate)

A generic SPIN template that can be used to declare a constraint that 
all values of a given property must have an rdf:type.


      Arguments

*arg:property* (rdf:Property): The property being constrained.


      Template body

CONSTRUCT {
     _:b0 a spin:ConstraintViolation .
     _:b0 spin:violationRoot ?this .
     _:b0 spin:violationPath ?property .
     _:b0 rdfs:label ?message .
}
WHERE {
     ?this ?property ?object .
     FILTER NOT EXISTS {
         ?object a ?anyType .
     } .
     BIND (CONCAT("Value ", ?object, " must have a type") AS ?message) .
}

------------------------------------------------------------------------


On 7/24/2014 2:20, Karen Coyle wrote:
> Holger, if the minimum profile could include (or link to) a list of 
> properties in the vocabulary, we could add those to the requirements 
> being gathered in the RDF AP requirements database.[1]
>
> Thanks,
> kc
> [1] http://purl.org/net/rdf-validation
>
> On 7/23/14, 5:22 AM, Holger Knublauch wrote:
>> Here is a draft for a minimum sub-set of SPIN that could serve as input
>> to this WG:
>>
>>      http://spinrdf.org/spin-min.html
>>
>> I wrote this up quickly so there may be silly mistakes, but the main
>> point I am trying to get across is that SPIN is really a very small RDF
>> vocabulary that is easy to implement and hopefully easy to agree on as
>> part of a standardization process. Of course there will be details to
>> work out, but our starting point has been in production for over six
>> years, and seems to work well.
>>
>> To illustrate my point about SPIN templates to describe Shapes, please
>> compare the example at
>>
>>      http://spinrdf.org/spin-min.html#spl
>>
>> with the original Resource Shapes proposal at
>>
>> http://open-services.net/resources/tutorials/oslc-primer/resourceshapes/
>>
>> We are really talking about very similar things here. A difference is
>> that the starting point of SPIN is SPARQL, and I believe it has a nicely
>> self-contained structure that requires only a single execution engine
>> for templates and other, more expressive, constraints.
>>
>> As a bonus, SPIN includes a simple solution for representing rules (for
>> ontology mapping and inferences) and a semantic web-friendly mechanism
>> to extend SPARQL engines with new functions. While those are not needed
>> to represent "Shapes", I believe they are low-hanging fruits that will
>> appeal to a very large technical audience and generally open up new use
>> cases for semantic web technology.
>>
>> Regards,
>> Holger
>>
>>
>>
>

Received on Thursday, 24 July 2014 02:35:02 UTC