parameter value type in custom sh:ConstraintComponent with custom predicate

16 views
Skip to first unread message

Eugen Costezki

unread,
Dec 13, 2016, 10:17:11 AM12/13/16
to TopBraid Suite Users
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:
--------------------------------------

@prefix dash: <http://datashapes.org/dash#> .
@prefix swa: <http://topbraid.org/swa#> .
@prefix tosh: <http://topbraid.org/tosh#> .

  rdf:type owl:Ontology ;
  owl:imports <http://datashapes.org/dash> ;
  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: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" ;
.

Holger Knublauch

unread,
Dec 13, 2016, 6:06:31 PM12/13/16
to topbrai...@googlegroups.com
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
--
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 topbrai...@googlegroups.com
---
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 topbraid-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages