Functions Used for Testing Values
This topic describes the built-in SPARQL functions that runs tests against your data and return boolean values.
- BOUND: Tests whether the specified variable has a value bound to it.
- EXISTS: Tests to see if the specified graph pattern exists in the data.
- IN: Tests whether the specified value is found in one or more expressions.
- ISBLANK: Tests whether the specified argument is a blank node.
- ISIRI or ISURI: Tests whether the specified argument is an IRI or URI.
- ISLITERAL: Tests whether the specified argument is a literal value.
- ISNUMERIC: Tests whether the specified argument is a numeric value.
- LANGMATCHES: Tests whether the language tags match for string values.
- NOT EXISTS: Tests to see if a graph pattern does not exist in the data.
- NOT IN: Tests whether the specified value is not found in one or more expressions.
- SAMETERM: Tests whether the specified RDF terms are the same.
- STRENDS: Tests whether a string value ends with the specified substring.
- STRSTARTS: Tests whether a string value starts with the specified substring.
BOUND Syntax
Use the following syntax when incorporating BOUND functions in queries:
BOUND(?variable)
BOUND returns true if a variable has a value bound to it and false if it does not. The input variable can be any supported data type.
EXISTS and NOT EXISTS Syntax
Use the following syntax when incorporating EXISTS or NOT EXISTS functions in queries:
[ NOT ] EXISTS { graph_pattern }
IN and NOT IN Syntax
Use the following syntax when incorporating IN and NOT IN functions in queries:
FUNCTION(test_value, expression1 [,...])
Where test_value is the value to test whether or not it exists in any of the expressions that you specify.
ISBLANK, ISIRI, ISURI, ISLITERAL, ISNUMERIC Syntax
Use the following syntax when incorporating ISBLANK, ISIRI, ISURI, ISLITERAL, or ISNUMERIC functions in queries:
FUNCTION(expression)
Where expression evaluates to an RDF term type value: a literal value, URI, or blank node.
LANGMATCHES Syntax
Use the following syntax when incorporating LANGMATCHES functions in queries:
LANGMATCHES(expression, language_identifier)
Where expression is tested to see if it includes the language tag specified in language_idenitifer.
SAMETERM Syntax
Use the following syntax when incorporating SAMETERM functions in queries:
SAMETERM(term1, term2)
Where term1 and term2 are the RDF term type values to compare.
STRENDS Syntax
Use the following syntax when incorporating STRENDS functions in queries:
STRENDS(expression, end_string)
Where expression is the string value to find the end_string in. STRENDS returns true if expression ends in end_string and false if it does not.
STRSTARTS Syntax
Use the following syntax when incorporating STRSTARTS functions in queries:
STRSTARTS(expression, start_string)
Where expression is the string value to find the start_string in. STRSTARTS returns true if expression starts in start_string and false if it does not.