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. 1.2.0 The expected result of the test case, or nothing to indicate that an error is expected. true The test expression or SELECT query (anything that can be evaluated with spin:eval). A test to verify that a SPIN function or magic property works as expected, and to generate documentation of example uses of the function. Each TestCase consists of a SPARQL function call or an expression that can be executed with spin:eval, and an expected result. The test framework only needs to execute spin:eval on the expression and compare it with the expected result. Test case predicate instance class default value count optional test expression value type testResult age SPIN Overview Finds all constraints and rules attached to classes in the current graph, using spin:constraint, spin:constructor, spin:rule or their sub-properties. The result set will contain the associated class, the predicate, and the SPIN rule. class property rule bp 0 -2 Argument true the default value for the argument indicates whether the argument is optional true the property holding the values of each function call true a comment describing the argument Argument {?predicate} : {?valueType} true the value type of the 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:constraing, the body of this template will verify that a non-optional value exists and that it has the specified value type. optional false predicate value valueType true a comment describing the meaning of this attribute true the maximum number of values permitted for the property true the minimum number of values permitted for the property 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. the RDF property holding the attribute value minCount predicate maxCount valueType value true the type that all values of the property must have Attribute Attribute {?predicate} : {?valueType} [{?minCount},{?maxCount}] true the default value of the attribute SPIN Overview The dateTime or time argument. Extracts the seconds from a date/time literal. seconds A collection of functions that operate on date/time literals. true Date functions seconds A magic property that establishes a relationship between properties (left) and classes (right) to determine which properties are "relevant" for the class. Relevant means that they have the class in their domain and/or restrictions, including superclasses and sub-properties. Note that the performance of the body of this magic property has been optimized for the case in which the class is given, so ideally use this for queries such as ?property spl:relevantPropertyAtClass skos:Concept . class true superClass 0 -2 property 0 -2 The property. relevant property at class defaultValue predicate anyValue The predicate to infer the default value of. The default value to infer. Can be used to infer default values for a given subject/predicate combination. This is typically assigned as spin:rule to a class. If ?this does not already have a value for a given property {?predicate}, then this will infer the value {?defaultValue}. Infer default value Default value for {?predicate}: {?defaultValue} A collection of functions performing ontology-related operations. Ontology functions true 0 -2 Checks whether a given property (?arg1) is a (transitive) sub-property of another property (?arg2). The potential sub-property. The potential super-property. sub property of COALESCE Takes any number of arguments, and returns the first bound argument, starting at the left. COALESCE A collection of functions that are difficult to categorize. Misc functions true b The date or dateTime argument. Extracts the year from a date/time literal. year year datatype IF The function result if ?arg1 is true. A condition to evaluate - if true then the ?arg2 will be returned, otherwise ?arg3. The function result if ?arg1 is false. The SPARQL 1.1 built-in function IF. IF / the first operand Returns the arithmetic quotient of its operands. the second operand divide A collection of functions operating on numbers. Mathematical functions true A collection of functions that return a boolean value (true or false). Boolean functions true the subject that is expected to have the value Checks whether a given subject (?arg1) has at least one value of a given type (?arg3) for a given property (?arg2) or one of its sub-properties. the expected property the type to match against p -2 0 value hasValueOfType The date or dateTime argument. Extracts the day from a date/time literal. day day Gets the current date and time as an xsd:dateTime literal. now now unary minus the operand - Returns the operand ?arg1 with the sign reversed. If ?arg1 is positive, its negative is returned; if it is negative, its positive is returned. count IRI IRI Creates a IRI resource (node) from a given IRI string (?arg1). The IRI string to convert to a resource. Test-object-no value Returns the lexical form of ?arg1 (a literal); returns the codepoint representation of ?arg1 (an IRI). This is useful for examining parts of an IRI, for instance, the host-name. the node to convert to string str str A collection of functions that return strings. String functions true maxCount 0 -2 the expected value the property that is expected to hold the value the subject that is expected to have the value Checks whether a given resource (?arg1) has a given value (?arg3) for a given property (?arg2) or one of the sub-properties of it. hasValue IN The value to find. Checks whether the value on the left (?arg1) is one of the values on the right (?arg2, ?arg3 ...). IN The date or dateTime argument. Extracts the month from a date/time literal. month month the second operand Returns true if ?arg1 >= ?arg2. >= ge the first operand Argument value subject Gets the "first" subject of a given predicate (?arg1)/object (?arg2) combination. Note that if multiple values are present then the result might be unpredictably random. The predicate. The object. subject * Returns the arithmetic product of its operands. the first operand mul the second operand error Construct default values Construct default values This template can be attached as spin:constructor to a root class such as rdfs:Resource to ensure that SPIN processors assign default values to certain properties. Looks for any templates attached as spin:constraints to the types of ?this and then assigns their declared spl:defaultValues. defaultValue predicate directType type 0 -2 attribute CONSTRUCT { ?this ?predicate ?defaultValue .} WHERE { ?this rdf:type ?directType . ?directType rdfs:subClassOf* ?type . ?type spin:constraint ?attribute . ?attribute spl:defaultValue ?defaultValue . ?attribute spl:predicate ?predicate } testCase expected actual expr Runs all spl:TestCases on the current model. Run test cases isURI Checks whether a node is a URI. isURI the node to check class true the flags the match pattern Returns true if a string (?arg1) matches the regular expression supplied as a pattern (?arg2) as influenced by the value of flags (?arg3), otherwise returns false. the input string regex regex The dateTime or time argument. Extracts the hours from a date/time literal. hours hours valueType true A collection of functions that create URI resources. URI functions minCount2 minCount unary plus the operand + Returns the operand ?arg1 with the sign unchanged. Semantically, this operation performs no operation. The dateTime or time argument. Extracts the minutes from a date/time literal. minutes minutes the second operand - sub the first operand Returns the arithmetic difference of its operands. NOT IN Checks whether the value on the left (?arg1) is none of the values on the right (?arg2, ?arg3 ...). The value to find. NOT IN predicate the second number Returns the arithmetic sum of its operands. the first number + add Returns the language tag of ?arg1, if it has one. It returns "" if the literal has no language tag. Node that the RDF data model does not include literals with an empty language tag. lang lang the literal to get the language of The filter function EXISTS. The graph pattern is stored in sp:elements. EXISTS EXISTS langMatches langMatches the literal that is expected to have ?arg2 as language tag Returns true if language-tag (first argument) matches language-range (second argument) per the basic filtering scheme defined in [RFC4647] section 3.3.1. the language tag that ?arg1 must have t strlang Takes a string (?arg1) and a language (?arg2) and constructs a literal with a corresponding language tag. The string value. The language tag, e.g. "en-AU". strlang body body body body body vars vars body Function body must be either an Ask query or a Select with exactly one result variable le <= Returns true if ?arg1 <= ?arg2. the second operand the first operand str optional Checks whether a given literal is untyped. This function was introduced because the built-in datatype operand in SPARQL casts untyped literals to xsd:string, making it impossible to check it this way. This function here uses a work-around using sameTerm instead. isUntypedLiteral The literal to test. The predicate to get the object of. datatype 0 -2 the second operand class the first operand ne the second operand Returns true if ?arg1 != ?arg2. != The expression to evaluate. Should be a sp:Select, sp:Ask, a sp:Variable or an instance of a SPARQL function class, but may also be a simple RDF value. the second operand the node being checked the type that the instance must have The subject to get the object from. Gets the object of a given subject (?arg1) / predicate (?arg2) combination. Note that if multiple values are present then the result might be unpredictably random. object object Returns true if ?arg1 is bound to a value. Returns false otherwise. Variables with the value NaN or INF are considered bound. bound bound the variable or expression that is checked object objectCount the subject to get the number of objects of the property to get the number of values of Gets the number of values of a given property (?arg2) at a given subject (?arg1). The result is the number of matches of (?arg1, ?arg2, ?object). the first operand ! Returns the boolean negation of the argument. not the operand to negate the second argument the second operand of the intersection the first operand of the intersection the literal to get the datatype of the instance being tested {?arg1} instance of {?arg2} Checks whether a given resource (?arg1) has a given type (?arg2). In order to fulfill this condition, there must either be a triple ?arg1 rdf:type ?arg2, or ?instance rdf:type ?subClass where ?subClass is a subclass of ?arg2. If the first argument is a literal, then the second argument must be the matching XSD datatype. instanceOf the second operand the node being tested the second value to compare Returns true if ?arg1 < ?arg2. lt < the first operand Returns true if both arguments are equal. the first value to compare eq = the first operand && and Return the logical AND between two (boolean) operands. the first argument isBlank Checks whether a given node is a blank node. isBlank NOT EXISTS The filter function NOT EXISTS. The graph pattern is stored in sp:elements. NOT EXISTS or Returns the logical OR between two (boolean) operands. || the node being tested isIRI Checks whether a given node is a IRI node. isIRI Returns TRUE if ?arg1 and ?arg2 are the same RDF term as defined in Resource Description Framework (RDF): Concepts and Abstract Syntax [CONCEPTS]; returns FALSE otherwise. sameTerm same term datatype Returns the datatype IRI of argument ?arg1; returns xsd:string if the parameter is a simple literal. datatype Returns true if ?arg1 > arg2. gt > isLiteral Checks whether a given node is a literal. isLiteral