Argument

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:constraint, the body of this template will verify that a non-optional value exists and that it has the specified value type. Arguments that have been declared spl:optional true become optional if the type of ?this is spl:UnionTemplate.

Body

A8

Text
PREFIX  xsd:  <http://www.w3.org/2001/XMLSchema#>
PREFIX  afn:  <http://jena.apache.org/ARQ/function#>
PREFIX  rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX  rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX  spin: <http://spinrdf.org/spin#>

CONSTRUCT 
  { 
    _:c0 a spin:ConstraintViolation .
    _:c0 spin:violationRoot ?this .
    _:c0 spin:violationPath ?predicate .
    _:c0 spin:violationValue ?value .
    _:c0 rdfs:label ?label .
  }
WHERE
  {   { FILTER ( ( ! bound(?optional) ) || ( ?optional = false ) )
        FILTER NOT EXISTS { ?this  ?predicate  ?value }
        # FILTER isIRI(?this)
        BIND(concat("Missing value for argument ", afn:localname(?predicate)) AS ?label)
      }
    UNION
      { FILTER bound(?valueType)
          { ?this  ?predicate  ?value
            # FILTER isIRI(?this)
            FILTER ( isURI(?value) || isBlank(?value) )
            FILTER bound(?valueType)
            FILTER ( ( ?valueType != rdfs:Resource ) || isLiteral(?value) )
            FILTER NOT EXISTS { ?value  a  ?class .
                                ?class (rdfs:subClassOf)* ?valueType
                              }
          }
        UNION
          { ?this  ?predicate  ?value
            # FILTER isIRI(?this)
            FILTER isLiteral(?value)
            FILTER bound(?valueType)
            FILTER ( ( ?valueType != rdfs:Resource ) || isLiteral(?value) )
            BIND(datatype(?value) AS ?datatype)
            FILTER ( ! ( ( ?datatype IN (?valueType, rdfs:Literal) ) || ( ( ( ! bound(?datatype) ) || ( ?datatype = rdf:langString ) ) && ( ?valueType = xsd:string ) ) ) )
          }
        BIND(concat("Incorrect type of argument ", afn:localname(?predicate), " (expected: ", afn:localname(?valueType), ")") AS ?label)
      }
  }
Comment
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:constraint, the body of this template will verify that a non-optional value exists and that it has the specified value type. Arguments that have been declared spl:optional true become optional if the type of ?this is spl:UnionTemplate.
Constraint

A10

a comment describing the argument

Comment
a comment describing the argument
Optional
true
Predicate
comment
Value type
string

A5

the value type of the argument

Comment
the value type of the argument
Optional
true
Predicate
value type
Value type
Class

A6

the property holding the values of each function call

Comment
the property holding the values of each function call
Predicate
predicate
Value type
Property

A7

indicates whether the argument is optional

Comment
indicates whether the argument is optional
Optional
true
Predicate
optional
Value type
boolean

A9

the default value for the argument

Comment
the default value for the argument
Optional
true
Predicate
default value
Label
Argument
Label template
Argument {?predicate} : {?valueType}
SubClassOf
Construct templates

Attribute

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.

Body

A3

Text
PREFIX  xsd:  <http://www.w3.org/2001/XMLSchema#>
  PREFIX  rdfs: <http://www.w3.org/2000/01/rdf-schema#>
  PREFIX  rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
  PREFIX spin: <http://spinrdf.org/spin#>

  CONSTRUCT {
      _:b0 a spin:ConstraintViolation .
      _:b0 spin:violationRoot ?this .
      _:b0 spin:violationPath ?predicate .
      _:b0 spin:violationValue ?value .
  }
  WHERE
    {   { SELECT  (count(*) AS ?cardinality)
          WHERE
            { ?this  ?predicate  ?value
              FILTER bound(?minCount)
            }
          HAVING ( ?cardinality < ?minCount )
        }
      UNION
        { { SELECT  (count(*) AS ?cardinality)
            WHERE
              { ?this  ?predicate  ?value
                FILTER bound(?maxCount)
              }
            HAVING ( ?cardinality > ?maxCount )
          }
        }
      UNION
        { ?this  ?predicate  ?value
          FILTER ( isURI(?value) || isBlank(?value) )
          FILTER bound(?valueType)
          FILTER NOT EXISTS { ?value  a  ?class .
                              ?class (rdfs:subClassOf)* ?valueType
                            }
        }
      UNION
        { ?this  ?predicate  ?value
          FILTER isLiteral(?value)
          FILTER bound(?valueType)
          BIND(datatype(?value) AS ?datatype)
          FILTER ( ! ( ( ?datatype IN (?valueType, rdfs:Literal) ) || ( ( ( ! bound(?datatype) ) || ( ?datatype = rdf:langString ) ) && ( ?valueType = xsd:string ) ) ) )
        }
    }
Comment
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.
Constraint

A0

the default value of the attribute

Comment
the default value of the attribute
Optional
true
Predicate
default value

A1

a comment describing the meaning of this attribute

Comment
a comment describing the meaning of this attribute
Optional
true
Predicate
comment
Value type
string

A11

the minimum number of values permitted for the property

Comment
the minimum number of values permitted for the property
Optional
true
Predicate
minCount
Value type
integer

A12

the maximum number of values permitted for the property

Comment
the maximum number of values permitted for the property
Optional
true
Predicate
maxCount
Value type
integer

A2

the RDF property holding the attribute value

Comment
the RDF property holding the attribute value
Predicate
predicate
Value type
Property

A4

the type that all values of the property must have

Comment
the type that all values of the property must have
Optional
true
Predicate
value type
Value type
Class
Label
Attribute
Label template
Attribute {?predicate} : {?valueType} [{?minCount},{?maxCount}]
SubClassOf
Construct templates

boolean

Class

Label
default value
SubPropertyOf
arg

integer

maxCount

SubPropertyOf
count

minCount

SubPropertyOf
count

optional

Label
optional
Range
boolean
SubPropertyOf
arg

predicate

Label
predicate
SubPropertyOf
arg

Property

Resource

SPIN Standard Library

A collection of generally useful SPARQL functions (expressed as SPIN functions), and SPIN templates. Also provides a top-level classification of functions, and definitions of the standard SPARQL functions.

Comment
A collection of generally useful SPARQL functions (expressed as SPIN functions), and SPIN templates. Also provides a top-level classification of functions, and definitions of the standard SPARQL functions.
Imports
SPIN Modeling Vocabulary
Label
SPIN Standard Library
VersionInfo
1.4.2

string

value type

Label
value type
SubPropertyOf
arg