define transform rule

49 views
Skip to first unread message

Bohms, H.M. (Michel)

unread,
Sep 23, 2021, 6:01:11 AM9/23/21
to topbrai...@googlegroups.com

Hi David

 

In my input data from big excel I now have for instance the triple:

 

<urn:x-evn-master:def_shapes/bestekk_1654_N317__Dieren_-_Hoog_Keppel-1709-0500-000-01A1> sa-input:projectOmschrijving "bestekk 1654, N317 , Dieren - Hoog Keppel" ;

 

I want to use this info to instantiate a separate Project class.

 

I understand that here:

 

I have to add someway a shacl-af rule doing:

Insert triple: "<current name space/bestekk 1654, N317 , Dieren - Hoog Keppel> rdf:type sa:Project

 

(actually I have to do that for all rows and because they are all in same project I will get duplicate triples that are only 1 in the end, I hope)

 

I have to do that for all classes (and for all other classes then the first: add also triple relating them)

 

Can you give my a hint how/where to best define these insert rule?

 

Thx a lot, Michel

 

 

Dr. ir. H.M. (Michel) Bohms
Scientist Specialist
Structural Reliability

T +31 (0)88 866 31 07
M +31 (0)63 038 12 20
michel...@tno.nl

Location

 

This message may contain information that is not intended for you. If you are not the addressee or if this message was sent to you by mistake, you are requested to inform the sender and delete the message. TNO accepts no liability for the content of this e-mail, for the manner in which you use it and for damage of any kind resulting from the risks inherent to the electronic transmission of messages.

 

David Price

unread,
Sep 23, 2021, 7:02:02 AM9/23/21
to topbrai...@googlegroups.com
SHACL rules are defined here:


What I typically do is make a separate graph for the rules and edit it in Composer, in the new Files feature or in Source Code editor. You can then include that graph and then remove it when the conversion is finished.

You define the rules (via sh:rule referencing a sh:SPARQLRule) on the “source” classes, and in the WHERE clause $this is instances of that classs, and then CONSTRUCT instances of “target" classes.

Cheers,
David

On 23 Sep 2021, at 11:01, 'Bohms, H.M. (Michel)' via TopBraid Suite Users <topbrai...@googlegroups.com> wrote:

Hi David
 
In my input data from big excel I now have for instance the triple:
 
<urn:x-evn-master:def_shapes/bestekk_1654_N317__Dieren_-_Hoog_Keppel-1709-0500-000-01A1> sa-input:projectOmschrijving "bestekk 1654, N317 , Dieren - Hoog Keppel" ;
 
I want to use this info to instantiate a separate Project class.
 
I understand that here:
<image002.png>
 
I have to add someway a shacl-af rule doing:
Insert triple: "<current name space/bestekk 1654, N317 , Dieren - Hoog Keppel> rdf:type sa:Project
 
(actually I have to do that for all rows and because they are all in same project I will get duplicate triples that are only 1 in the end, I hope)
 
I have to do that for all classes (and for all other classes then the first: add also triple relating them)
 
Can you give my a hint how/where to best define these insert rule?
 
Thx a lot, Michel
 
 
Dr. ir. H.M. (Michel) Bohms
Scientist Specialist
Structural Reliability
T +31 (0)88 866 31 07
M +31 (0)63 038 12 20
michel...@tno.nl
This message may contain information that is not intended for you. If you are not the addressee or if this message was sent to you by mistake, you are requested to inform the sender and delete the message. TNO accepts no liability for the content of this e-mail, for the manner in which you use it and for damage of any kind resulting from the risks inherent to the electronic transmission of messages. 
 

-- 
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/f994e032f1c4487c8b99e264295c6142%40tno.nl.


Bohms, H.M. (Michel)

unread,
Sep 23, 2021, 7:22:09 AM9/23/21
to topbrai...@googlegroups.com

              Ahh, ok, so in my case I would add to the source class sa-input:Monsterlaag :

 

sh:rule [

                            a sh:TripleRule ;

                            sh:subject (sh:this ATTRIBUTE projectName as URI) ;

                            sh:predicate rdf:type ;

                            sh:object sa:Project ;

              ] .

 

Apart from the yellow I can also think of putting the rule at the target:

 

sa:ProjectShape

              a sh:NodeShape ;

              sh:targetClass sa:Project ;

              sh:rule [

                            a sh:SPARQLRule ;

                            sh:prefixes sa: ;

                            sh:construct """

                                          CONSTRUCT {

                                                         ?uri rdf:type sa:Project .

                                          }

                                          WHERE {

                                                         ?someproject sa-input:projectNaam ?projectNaam .

                                                         ? Uri = ….( projectNaam)

                                          }

                                          """ ;

              ] ;

.

 

Again having a similar yellow part I have to find the right predefined function for…

 

???

 

 

Dr. ir. H.M. (Michel) Bohms
Scientist Specialist
Structural Reliability

T +31 (0)88 866 31 07
M +31 (0)63 038 12 20
michel...@tno.nl

Location

 

This message may contain information that is not intended for you. If you are not the addressee or if this message was sent to you by mistake, you are requested to inform the sender and delete the message. TNO accepts no liability for the content of this e-mail, for the manner in which you use it and for damage of any kind resulting from the risks inherent to the electronic transmission of messages.

David Price

unread,
Sep 23, 2021, 7:50:05 AM9/23/21
to topbrai...@googlegroups.com
Not quite and I think I confused you by mentioning “target” by which I did NOT mean sh:targetClass. 

Put the actual SPARQLRule against the source class so that $this refers to instances of that class. There is no need for TripleRule. More like this but using $this in the WHERE rule to iterate through the instances of the class:

add to the source class sa-input:Monsterlaag :

 sh:rule [
                            a sh:SPARQLRule ;
                            sh:prefixes sa: ;
                            sh:construct """
                                          CONSTRUCT {
                                                         ?uri rdf:type sa:Project .
                                          }
                                          WHERE {
                                                         ?someproject sa-input:projectNaam ?projectNaam .
                                                         ? Uri = ….( projectNaam)
                                          }
                                          """ ;
              ] ;
.

but 

WHERE {
$this sa-input:SomeAttrOf Monsterlaag ?value .
$this sa-input:SomeOtherAttrOf Monsterlaag ?valueother .
Etc

Cheers,
David



Bohms, H.M. (Michel)

unread,
Sep 23, 2021, 8:44:33 AM9/23/21
to topbrai...@googlegroups.com
Think you did not confuse me with target. I meant target class being the class i want to transform to...in the target ontology sa.

I think the below pattern does not do the job for me.
I have to create new instances of sa:Project etc. based on the existing MonsterLaag instance.

Based on!

That is...i use an attribute value of that instance to create an new target instance. Being projectNaam.

This transformation will in a sense normalise my original excel relation splitting it into subtables.

I just need to find again the way to create such an instance.

Some swp function i used to use in spin in the past...... and bind the result in a where clause i think...
???


Op 23 sep. 2021 13:50 schreef David Price <dpr...@topquadrant.com>:

David Price

unread,
Sep 23, 2021, 9:08:06 AM9/23/21
to topbrai...@googlegroups.com

On 23 Sep 2021, at 13:44, 'Bohms, H.M. (Michel)' via TopBraid Suite Users <topbrai...@googlegroups.com> wrote:

Think you did not confuse me with target. I meant target class being the class i want to transform to...in the target ontology sa.

I think the below pattern does not do the job for me.
I have to create new instances of sa:Project etc. based on the existing MonsterLaag instance.

Based on!

Yes, I understood that.


That is...i use an attribute value of that instance to create an new target instance. Being projectNaam.

This transformation will in a sense normalise my original excel relation splitting it into subtables.

I just need to find again the way to create such an instance.

Some swp function i used to use in spin in the past...... and bind the result in a where clause i think...
???

SPARQL functions probably. BIND, IRI, CONCAT are usually enough.


Cheers,
David

Bohms, H.M. (Michel)

unread,
Sep 23, 2021, 9:16:42 AM9/23/21
to topbrai...@googlegroups.com
Thx David
I'l try that.

Op 23 sep. 2021 15:08 schreef David Price <dpr...@topquadrant.com>:

Bohms, H.M. (Michel)

unread,
Sep 23, 2021, 2:43:56 PM9/23/21
to topbrai...@googlegroups.com

Ok, i tried:

 

 

But the query stays red….

 

 

 

Dr. ir. H.M. (Michel) Bohms
Scientist Specialist
Structural Reliability

T +31 (0)88 866 31 07
M +31 (0)63 038 12 20
michel...@tno.nl

Location

 

Irene Polikoff

unread,
Sep 24, 2021, 3:54:47 AM9/24/21
to topbrai...@googlegroups.com
I don’t know about red, but you need to associate a rule with a class that has instances, not with a class does not have any.

This is what David said - build a rule to process instances of a class that you have. Associating a rule with something that has no data will not do anything.


You could add a rule to a node shape that is not a class. Then, you need an explicit target statement. Target delivers resources over which a rule can operate to generate new triples based on the information that exists about these resources.

On Sep 23, 2021, at 2:43 PM, 'Bohms, H.M. (Michel)' via TopBraid Suite Users <topbrai...@googlegroups.com> wrote:



Ok, i tried:

 

<image001.png>

 

But the query stays red….

 

 

 

Dr. ir. H.M. (Michel) Bohms
Scientist Specialist
Structural Reliability

T +31 (0)88 866 31 07
M +31 (0)63 038 12 20
michel...@tno.nl

Location

 

Bohms, H.M. (Michel)

unread,
Sep 24, 2021, 6:07:22 AM9/24/21
to topbrai...@googlegroups.com

Ok, then indeed ‘sh:this’ makes sense then…

So I have to define the shape at the source being sa-input:MonsterLaag

 

Guess the red text is just a highlight of the sparql code, not an error …(I could save the shape so…)

 

The only question left then for now is the sh:prefixes

How can I indicate multiple of them

I assume I have to indicate those that are used in both the construct and the where part?

 

Many thx

 

 

Dr. ir. H.M. (Michel) Bohms
Scientist Specialist
Structural Reliability

T +31 (0)88 866 31 07
M +31 (0)63 038 12 20
michel...@tno.nl

Location

 

This message may contain information that is not intended for you. If you are not the addressee or if this message was sent to you by mistake, you are requested to inform the sender and delete the message. TNO accepts no liability for the content of this e-mail, for the manner in which you use it and for damage of any kind resulting from the risks inherent to the electronic transmission of messages.

Bohms, H.M. (Michel)

unread,
Sep 24, 2021, 6:45:10 AM9/24/21
to topbrai...@googlegroups.com

Wrt prefixes issue

 

Guess because sa-input is not in the list of name spaces:

 

PREFIX dash: http://datashapes.org/dash#

PREFIX dc: http://purl.org/dc/elements/1.1/

PREFIX dct: http://purl.org/dc/terms/

PREFIX edg: http://edg.topbraid.solutions/model/

PREFIX graphql: http://datashapes.org/graphql#

PREFIX metadata: http://topbraid.org/metadata#

PREFIX nen2660: https://w3id.org/nen2660/def#

PREFIX nen2660-term: https://w3id.org/nen2660/term#

PREFIX owl: http://www.w3.org/2002/07/owl#

PREFIX quantitykind: http://qudt.org/vocab/quantitykind/

PREFIX qudt: http://qudt.org/schema/qudt/

PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#

PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#

PREFIX sa: https://w3id.org/sa/def#

PREFIX sh: http://www.w3.org/ns/shacl#

PREFIX skos: http://www.w3.org/2004/02/skos/core#

PREFIX skosxl: http://www.w3.org/2008/05/skos-xl#

PREFIX teamwork: http://topbraid.org/teamwork#

PREFIX time: http://www.w3.org/2006/time#

PREFIX unit: http://qudt.org/vocab/unit/

PREFIX xsd: http://www.w3.org/2001/XMLSchema#

 

 

Strange, because I imported sa-input.ttl, last item in:

 

<urn:x-evn-master:def_shapes>

  a http://teamwork.topbraidlive.org/ontologyprojects#Ontology ;

  a teamwork:Vocabulary ;

  a owl:Ontology ;

  graphql:publicClass sa-input:MonsterLaag ;

  metadata:status metadata:UnderDevelopmentStatus ;

  teamwork:externalGraphURI https://w3id.org/sa/owl/def ;

  rdfs:label "def Shapes" ;

  owl:imports http://datashapes.org/graphql ;

  owl:imports http://qudt.org/schema/qudt ;

  owl:imports http://qudt.org/vocab/quantitykind ;

  owl:imports http://qudt.org/vocab/unit ;

  owl:imports http://topbraid.org/teamworkconstraints ;

  owl:imports http://www.w3.org/2004/02/skos/core ;

  owl:imports http://www.w3.org/2006/time ;

  owl:imports http://www.w3.org/ns/shacl ;

  owl:imports https://w3id.org/nen2660/owl/def ;

  owl:imports https://w3id.org/nen2660/rdfs/def ;

  owl:imports https://w3id.org/sa-input/owl/def ;

.

 

In this file it says:

 

# baseURI: https://w3id.org/sa-input/owl/def

# imports: http://topbraid.org/tables

 

@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 sa-input: https://w3id.org/sa-input/def# .

@prefix xsd: http://www.w3.org/2001/XMLSchema# .

 

 

And its seems to be known by EDG, given

 

 

It file (graph uri) IS shown in:

 

But the name space uri/prefix seems missing in the setting..

 

Any idea?

Can I just add it?

 

 

Dr. ir. H.M. (Michel) Bohms
Scientist Specialist
Structural Reliability

T +31 (0)88 866 31 07
M +31 (0)63 038 12 20
michel...@tno.nl

Location

 

This message may contain information that is not intended for you. If you are not the addressee or if this message was sent to you by mistake, you are requested to inform the sender and delete the message. TNO accepts no liability for the content of this e-mail, for the manner in which you use it and for damage of any kind resulting from the risks inherent to the electronic transmission of messages.

 

Bohms, H.M. (Michel)

unread,
Sep 24, 2021, 6:49:12 AM9/24/21
to topbrai...@googlegroups.com

One more brainwave:

 

Is it the dash in sa-input giving problems?

Bohms, H.M. (Michel)

unread,
Sep 24, 2021, 7:06:39 AM9/24/21
to topbrai...@googlegroups.com

Seems not the case:

I reimported

 

Now:

Its in the list, but now:

 

It is not used by edg:

 

 

Totally lost….

 

When I look in code of MonsterLaag:

 

@prefix afn: http://jena.hpl.hp.com/ARQ/function# .

@prefix arg: http://spinrdf.org/arg# .

@prefix constant: http://qudt.org/vocab/constant/ .

@prefix creativecommons: http://creativecommons.org/ns# .

@prefix dash: http://datashapes.org/dash# .

@prefix dc: http://purl.org/dc/elements/1.1/ .

@prefix dct: http://purl.org/dc/terms/ .

@prefix dcterms: http://purl.org/dc/terms/ .

@prefix dtype: http://www.linkedmodel.org/schema/dtype# .

@prefix edg: http://edg.topbraid.solutions/model/ .

@prefix fn: http://www.w3.org/2005/xpath-functions# .

@prefix functions: http://qudt.org/2.1/schema/extensions/functions# .

@prefix graphql: http://datashapes.org/graphql# .

@prefix imports: http://qudt.org/2.1/schema/extensions/imports# .

@prefix mc: http://www.linkedmodel.org/owl/schema/core# .

@prefix metadata: http://topbraid.org/metadata# .

@prefix nen2660: https://w3id.org/nen2660/def# .

@prefix nen2660-term: https://w3id.org/nen2660/term# .

@prefix sa: https://w3id.org/sa/def# .

@prefix sh: http://www.w3.org/ns/shacl# .

@prefix skos: http://www.w3.org/2004/02/skos/core# .

@prefix skosxl: http://www.w3.org/2008/05/skos-xl# .

@prefix smf: http://topbraid.org/sparqlmotionfunctions# .

@prefix sou: http://qudt.org/vocab/sou/ .

@prefix sp: http://spinrdf.org/sp# .

@prefix spif: http://spinrdf.org/spif# .

@prefix spin: http://spinrdf.org/spin# .

@prefix spl: http://spinrdf.org/spl# .

@prefix swa: http://topbraid.org/swa# .

@prefix teamwork: http://topbraid.org/teamwork# .

@prefix teamworkconstraints: http://topbraid.org/teamworkconstraints# .

@prefix time: http://www.w3.org/2006/time# .

@prefix tosh: http://topbraid.org/tosh# .

@prefix unit: http://qudt.org/vocab/unit/ .

@prefix vaem: http://www.linkedmodel.org/schema/vaem# .

@prefix voag: http://voag.linkedmodel.org/voag/ .

There is no sa-input there!

 

?????

Reply all
Reply to author
Forward
0 new messages