Hi Eugen,
thanks for the details which allowed me to reproduce your situation
quickly. If you have a parameter (such as :hasNotValue) that has neither
sh:datatype nor sh:class constraints, TBC will allow you to enter either
a literal or a resource. By default the text field will expect a string
literal though. To enter a URI, open the context menu behind hasNotValue
and select "Add existing..." to open a selection dialog, or one of the
"Create XY" items from the same menu. And, as fallback, there is always
the source code editor. To verify that you have a URI resource, look out
for the purple diamond icon, compared to the blue rectangle for datatype
literals.
HTH
Holger
On 14/12/2016 1:17, Eugen Costezki wrote:
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:
--------------------------------------
# baseURI: http://eurovoc.europa.eu/euvocShapesUtil
# imports: http://datashapes.org/dash
# imports: http://www.w3.org/2004/02/skos/core
# imports: http://www.w3.org/ns/shacl#
@prefix : <http://eurovoc.europa.eu/euvocShapesUtil#> .
@prefix dash: <http://datashapes.org/dash#> .
@prefix euvocShapes:
<http://publications.europa.eu/ontology/euvoc/euvocShapes#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix swa: <http://topbraid.org/swa#> .
@prefix tosh: <http://topbraid.org/tosh#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://eurovoc.europa.eu/euvocShapesUtil>
rdf:type owl:Ontology ;
owl:imports <http://datashapes.org/dash> ;
owl:imports <http://www.w3.org/2004/02/skos/core> ;
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:isDefinedBy <http://eurovoc.europa.eu/euvocShapesUtil> ;
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:editWidget
<http://topbraid.org/tosh.ui#UseDeclaredDatatypeEditor> ;
tosh:useDeclaredDatatype "true"^^xsd:boolean ;
] ;
sh:propertyValidator [
rdf:type sh:SPARQLSelectValidator ;
sh:labelTemplate "{$path1} is something"@en ;
sh:message "Encountered forbidden value {$hasNotValue}" ;
sh:prefixes <http://datashapes.org/dash> ;
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" ;
.
--
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include the TopBraid
Suite family of products and its base technologies such as
SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to [email protected]
---
You received this message because you are subscribed to the Google
Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Group "TopBraid
Suite Users", the topics of which include the TopBraid Suite family of products and
its base technologies such as SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to [email protected]
---
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.