Ok, we have a disconnect then. I was running the file you had attached and in 
my version (7.5) I only got one violation while the script constraint worked 
fine.

What version are you on?

Also, note you can debug what's going on in your constraint by adding something 
like 

let inferred = focusNode.value(ex.inferred);
console.log('Inf: ' + inferred + ' type is ' + typeof inferred);

With the Script Console open you should get a better understanding of what it 
really is comparing. One theory is that it's returning a complex JS object 
instead of a JS number, although I have no explanation for that.

Holger

> On 1 Mar 2023, at 3:44 pm, Hamid Abdirad <[email protected]> wrote:
> 
> Thank you for your response, Holger. There are two violations in the 
> screenshot above. 
> 
> The big red flag in the screenshot with custom message "integer value does 
> not match inferred value" actually comes from the ADS constraint. 
> The turtle file I attached earlier shows it: dash:js 
> "focusNode.value(ex.inferred) == focusNode.value(ex.notInferred)" ;
> 
> This part confuses me: how come  focusNode.value(ex.inferred) can be compared 
> against a constant like 30 in your example, but not against the property 
> value  focusNode.value(ex.notInferred). 
> 
> Thank you,
> Hamid
> 
> On Wednesday, March 1, 2023 at 1:47:32 AM UTC-8 Holger Knublauch wrote:
>> Ah I now understand what you mean. The violation is produced by the 
>> sh:equals constraint at ex:TextClass-notInferred. It has nothing to do with 
>> the ADS ScriptConstraint.
>> 
>> None of the constraints outside of the ADS constraints will "see" the 
>> inferred values, because the inferences only happen when requested, e.g. 
>> from API calls like focusNode.value(ex.inferred) and from GraphQL which is 
>> used by the user interface forms. In other words, the inferences are only 
>> computed on-the-fly but do not become triples... unless you assert them, 
>> e.g. from the Transform tab.
>> 
>> Does this clarify things?
>> 
>> Holger
>> 
>> 
>>> On 28 Feb 2023, at 9:07 pm, Hamid Abdirad <[email protected] <>> wrote:
>>> 
>> 
>>> I attached the sample ttl file for your review. This screenshot shows that  
>>> the script editor evaluates the statement as true but the constraint 
>>> evaluates it as false, thus 59 and 59 are not considered equal. 
>> 
>>> 
>>> <5.jpg>
>> 
>>> 
>>> Please let me know if this example clarifies the issue.
>>> Thank you,
>>> Hamid
>>> On Tuesday, February 28, 2023 at 11:58:23 AM UTC-8 Holger Knublauch wrote:
>>>> This doesn't look right:
>>>> 
>>>>    focusNode.value(ex:integerProperty) == 
>>>> focusNode.value(ex:inferredProperty)
>>>> 
>>>> Did you mean ex.integerProperty?
>>>> 
>>>> Holger
>>>> 
>>>> 
>>>>> On 28 Feb 2023, at 7:42 pm, Hamid Abdirad <[email protected] <>> wrote:
>>>>> 
>>>> 
>>>>> Hi Holger, Thank you for your reply. 
>>>>> The example you shared works fine for me. However, my example, is not 
>>>>> self referencing. Basically, my property A (integer) wants to look at the 
>>>>> inferred value of property B but it does not see any value in B (but UI 
>>>>> shows the value). 
>>>> 
>>>>> Here is the example shapes and screenshot:
>>>>> 
>>>>> ex:TestClass
>>>>>   a owl:Class ;
>>>>>   a sh:NodeShape ;
>>>>>   dash:scriptConstraint [
>>>>>       a dash:ScriptConstraint ;
>>>>>       dash:js "focusNode.value(ex:integerProperty) == 
>>>>> focusNode.value(ex:inferredProperty)" ;
>>>>>       sh:message "Integer value must match the inferred value" ;
>>>>>     ] ;
>>>>>   rdfs:label "Test class" ;
>>>>>   rdfs:subClassOf owl:Thing ;
>>>>>   sh:property ex:TestClass-inferredProperty ;
>>>>>   sh:property ex:TestClass-integerProperty ;
>>>>> .
>>>>> ex:TestClass-inferredProperty
>>>>>   a sh:PropertyShape ;
>>>>>   sh:path ex:inferredProperty ;
>>>>>   sh:class xsd:integer ;
>>>>>   sh:name "inferredProperty" ;
>>>>>   sh:values [
>>>>>       dash:js "focusNode.uri.length" ;
>>>>>     ] ;
>>>>> .
>>>>> ex:TestClass-integerProperty
>>>>>   a sh:PropertyShape ;
>>>>>   sh:path ex:integerProperty ;
>>>>>   sh:datatype xsd:integer ;
>>>>>   sh:equals ex:inferredProperty ;
>>>>>   sh:name "integerProperty" ;
>>>>> .
>>>>> 
>>>>> I also added the sh:equals constraint to check if the persisted integer 
>>>>> value equals the inferred property but neither the script nor the 
>>>>> sh:equals worked as expected. 
>>>>> 
>>>> 
>>>>> <3.jpg>
>>>>> Thank you,
>>>>> Hamid
>>>>> 
>>>> 
>>>>> On Tuesday, February 28, 2023 at 1:33:27 AM UTC-8 Holger Knublauch wrote:
>>>>>> Hello Hamid,
>>>>>> 
>>>>>> I have attached an example file that - I believe - demonstrates that 
>>>>>> inferences are being executed as part of constraint checks.
>>>>>> 
>>>>>> The main definitions are:
>>>>>> 
>>>>>> ex:TestClass
>>>>>>   a owl:Class ;
>>>>>>   a sh:NodeShape ;
>>>>>>   dash:scriptConstraint [
>>>>>>       a dash:ScriptConstraint ;
>>>>>>       dash:js "focusNode.value(ex.inferred) >= 30" ;
>>>>>>       sh:message "URI must have at least 30 chars" ;
>>>>>>     ] ;
>>>>>>   rdfs:label "Test class" ;
>>>>>>   rdfs:subClassOf owl:Thing ;
>>>>>>   sh:property ex:TestClass-inferred ;
>>>>>> .
>>>>>> ex:TestClass-inferred
>>>>>>   a sh:PropertyShape ;
>>>>>>   sh:path ex:inferred ;
>>>>>>   sh:datatype xsd:integer ;
>>>>>>   sh:name "inferred" ;
>>>>>>   sh:values [
>>>>>>       dash:js "focusNode.uri.length" ;
>>>>>>     ] ;
>>>>>> .
>>>>>> 
>>>>>> where ex:inferred is computed to be the length of the URI and the 
>>>>>> constraint requires that the length >= 30.
>>>>>> 
>>>>>> In my local tests that is working fine.
>>>>>> 
>>>>>> If that same example does not work for you, then you may be on a 
>>>>>> different version than I am.
>>>>>> 
>>>>>> Could you compare this with your own test and send me a minimal 
>>>>>> self-contained example that I can run locally if it still does not work 
>>>>>> for you?
>>>>>> 
>>>>>> Regards
>>>>>> Holger
>>>>>> 
>>>>> 
>>>>> 
>>>> 
>>>>> -- 
>>>>> 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] <>.
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/topbraid-users/8051c67f-905a-4c21-a973-e968faa6e5dan%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/topbraid-users/8051c67f-905a-4c21-a973-e968faa6e5dan%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>>>> <3.jpg>
>>>> 
>>> 
>>> 
>>> -- 
>>> 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] <>.
>> 
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/topbraid-users/a9e11bea-535a-403b-b388-3b4d6413e7c6n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/topbraid-users/a9e11bea-535a-403b-b388-3b4d6413e7c6n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>> <5.jpg><constraint-inference.test(2).ttl>
>> 
> 
> 
> -- 
> 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]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/topbraid-users/e9f1f412-277b-4e8e-88ac-5590753ac4ebn%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/topbraid-users/e9f1f412-277b-4e8e-88ac-5590753ac4ebn%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
The topics of this mailing list include TopBraid EDG and related technologies 
such as SHACL.
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/topbraid-users/578AEF14-7ECE-47D5-9554-531465DF12EE%40topquadrant.com.

Reply via email to