Ok, let’s assume the simple case for now, where we have ex:USA ex:region 
ex:NorthAmerica. Then let’s assume we have an ex:Address class with properties 
ex:country and ex:inferredRegion. Once the user selects USA and saves changes, 
the inferred value should show up:

ex:Address
    a owl:Class, sh:NodeShape ;
    sh:property ex:Address-country ;
    sh:property ex:Address-inferredRegion ;
…

ex:Address-inferredRegion
    a sh:PropertyShape ;
    sh:path ex:inferredRegion ;
    sh:values [
        sh:path ( ex:country ex:region ) ;
    ] .

The design above uses a path expression (SHACL node expression) that gets the 
asserted region of the asserted country. The complete syntax of such node 
expressions is defined in 
https://w3c.github.io/shacl/shacl-af/#node-expressions 
<https://w3c.github.io/shacl/shacl-af/#node-expressions>

If you need something more complex, you can define sh:values rules using 
JavaScript/ADS or SPARQL. When you enter sh:values rules on the form, the 
system actually suggests to use JavaScript. To enter SPARQL, the syntax would 
be like

sh:values [
    sh:select “””
        PREFIX ex: ...
        SELECT ?region
        WHERE {
            $this ex:country / ex:region ?region .
        } “”” ;
]

HTH
Holger
 

> On 28 Jul 2022, at 10:04 am, Fan Li <[email protected]> wrote:
> 
> Hi Holger, thanks for your reply. In this case, the two attributes may be 
> linked by an existing triple (ex:USA ex:region ex:NorthAmerica). In other 
> cases, they may be linked by some SHACL property value rule or custom SPARQL 
> query.
> 
> My question is when a user enters value in one attribute, how can we 
> automatically populate the other attribute in the user interface? Do I just 
> need to set "sh:values" for the 2nd attribute? Could you please provide an 
> example?
> 
> On Thursday, July 28, 2022 at 8:54:37 AM UTC-4 [email protected] wrote:
> Hi Fan Li,
> 
> What would be the formula (in prose) to infer the region from a country? If 
> that info is already stored as a triple such as ex:USA ex:region 
> ex:NorthAmerica then you wouldn’t need an inference. But without such 
> triples, where would the sh:values rule look up that knowledge?
> 
> Holger
> 
> 
> 
>> On 28 Jul 2022, at 7:29 am, Fan Li <[email protected] 
>> <applewebdata://C1DF41A9-26B1-4A2F-AF48-81436EEBABA2>> wrote:
>> 
> 
>> Sorry if this is a trivial question. I am picking up SHACL inference in EDG 
>> again. We'd like users to select a country (e.g. United States) and 
>> automatically infer the region it belongs to (e.g. North America). How to 
>> accomplish this in EDG? Thanks!
>> 
> 
>> -- 
>> 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] 
>> <applewebdata://C1DF41A9-26B1-4A2F-AF48-81436EEBABA2>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/topbraid-users/049f1b19-1fa5-4261-a21f-470b9aa4488dn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/topbraid-users/049f1b19-1fa5-4261-a21f-470b9aa4488dn%40googlegroups.com?utm_medium=email&utm_source=footer>.
> 
> 
> -- 
> 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/acd10941-e10d-41b5-bca3-1147bae6bf4en%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/topbraid-users/acd10941-e10d-41b5-bca3-1147bae6bf4en%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
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/AA19FB3F-3090-4631-92C7-8938245D3C60%40topquadrant.com.

Reply via email to