Dear Sir/Madam
Below is a simple definition of a custom shape based on sh:HasValueConstraintComponent.
What I try to achieve is the opposite functionality, i.e. the errors are considered any node having value ($hasNotValue) on given property ($PATH).
To do that I
(1) replace the queries
(2) define a new property and
(3) a new parameter (see code below)
The queries
# "Has value" query
SELECT $this
WHERE {
FILTER NOT EXISTS { $this $PATH $hasValue }
}
# "Has not value" query
SELECT $this
WHERE {
$this $PATH $hasNotValue .
}
The problem is that this works if I pass string values to the parameter (hasNotValue) but as soon as I pass an URI written in short form (skos:ConceptScheme) it is still considered a string and not a URI. To make it work for URIs I have to cast the variable $hasNotValue and ?value into string and compare them as strings which is quite inconvenient.
The Question is how can I write the constraint component and still preserve the "any value type" feature for the parameter values?
Below is the code of the Constraintcomponent definition and a test case:
--------------------------------------
rdf:type owl:Ontology ;
owl:imports sh: ;
owl:versionInfo "EuVoc 1.1" ;
.
:hasNotValue
rdf:type rdf:Property ;
rdfs:comment """
Specifies a value that must NOT be among the value nodes.
"""^^rdf:HTML ;
rdfs:label "hasNotValue" ;
.
:hasNotValueHasNotValueConstraintComponent
rdf:type sh:ConstraintComponent ;
dash:propertySuggestionGenerator [
rdf:type dash:SPARQLUpdateSuggestionGenerator ;
sh:message "Remove or change {$hasNotValue} from the {$focusNode}" ;
sh:update """DELETE {
$focusNode $predicate $hasNotValue .
}
WHERE {
}""" ;
] ;
sh:parameter :hasNotValueHasNotValueConstraintComponent-hasNotValue ;
sh:property [
sh:predicate :hasNotValue ;
tosh:useDeclaredDatatype "true"^^xsd:boolean ;
] ;
sh:propertyValidator [
rdf:type sh:SPARQLSelectValidator ;
sh:labelTemplate "{$path1} is something"@en ;
sh:message "Encountered forbidden value {$hasNotValue}" ;
sh:select """SELECT $this
WHERE {
$this $PATH $hasNotValue .
# bind (datatype(?value) as ?dtv )
# bind ( iri($hasNotValue) as ?d )
# FILTER ( str(?value) = str(?hasNotValue) )
# FILTER NOT EXISTS { $this $PATH $hasNotValue }
}""" ;
] ;
sh:targetClass sh:PropertyConstraint ;
.
:hasNotValueHasNotValueConstraintComponent-hasNotValue
rdf:type sh:Parameter ;
sh:predicate :hasNotValue ;
sh:description "The forbiden value." ;
sh:name "hasNoteValue" ;
.
-------------------------------------------------
test case for predicate rdf:type ($PATH) and value skos:ConceptScheme ($hasNotValue)
---------------
:Concept_1_I
rdf:type skos:Concept ;
rdf:type skos:ConceptScheme ;
rdfs:comment "Concept 1 should violate S9" ;
rdfs:label "Concept 1" ;
owl:versionInfo "EuVoc 1.1" ;
.