Customize turtle file generation for persistence in git repository

49 views
Skip to first unread message

Kai Liu

unread,
May 26, 2022, 7:06:30 AM5/26/22
to TopBraid Suite Users
Hi,

I have now a requirement to automatically add "owl:imports" lines for all turtle file persisted in git repository. For example:

The asset colletion "a" includes the asset collection "b", and the resulting a.ttl in the git repository has the following triple:

<urn:x-evn-master:a> owl:imports <urn:x-evn-master:b>.

I'd like to add an additional triple automatically:

<urn:x-evn-master:a> owl:imports <file:b.ttl>.

This should be done for all included asset collections. Could you please suggest me how to do that? What script should be adapted and how? Thanks.

Regards, Kai



David Price

unread,
May 26, 2022, 9:27:00 AM5/26/22
to topbrai...@googlegroups.com
Hi,

Both the domain and the range of owl:imports are supposed to be named graph URIs (technically “ontology documents” in the OWL2 spec), not file names in a filesystem. 

See 


where is says:

The IRIs identifying the ontology documents of the directly imported ontologies can be redirected as described in Section 3.2. For example, in order to access the above mentioned ontology document from a local cache, the IRI <http://www.example.com/my/2.0> might be redirected to <file:///usr/local/ontologies/imported.v20.owl>. Note that this can be done without changing the ontology document of the importing ontology. 

So basically, you’re “perverting” what owl:imports is supposed to do but nothing to stop you doing it I guess.

There is a checkbox to “Include inferred statements from SHACL rules” in Export to RDF so I guess if you can write rules to generate the triple you want it would be added to the TTL file when saved. BTW if you bring that back into EDG it will complain about the missing import but will let the import work, you’d just need to go clean up the Includes.

Cheers,
David

--
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/18111a21-b9db-4574-8f62-053fc36d83ben%40googlegroups.com.


David Price

unread,
May 26, 2022, 10:06:15 AM5/26/22
to 'Felix Sasaki' via TopBraid Suite Users
Hi,

Forgot to mention that in Settings in each collection there is this:

External Graph URI

The external graph URI is an optional alias for the asset collection identifier, used when exporting an asset collection as serialized RDF graph. It can also be used on import of interconnected RDF files when they are loaded into different asset collections - to appropriately re-route their owl:imports references.


Cheers,
David



On 26 May 2022, at 12:06, Kai Liu <kai...@siemens.com> wrote:

--
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/18111a21-b9db-4574-8f62-053fc36d83ben%40googlegroups.com.

Kai Liu

unread,
May 26, 2022, 3:43:20 PM5/26/22
to TopBraid Suite Users
Thanks for the links and the info. 

I was talking about the EDG 7.2 feature "Commit Ontology to Git Repository". We found this feature extremely useful, and it saved us lots of tedious work of exporting, copying and renaming TTL files. With this feature, the "External Graph URI" of included sub-graph is not automatically persisted in the including sub-graph, however. 

Back to the origin of my question: I need to find a way to resolve <urn:x-evn-master:b> to a local file b.ttl, which was exported to the same directory as a.ttl in the git repository. I need to run the SHACL validator (https://github.com/TopQuadrant/shacl), which can not understand "<urn:x-evn-master:a> owl:imports <urn:x-evn-master:b>", but does understand  "<urn:x-evn-master:a> owl:imports <file:b.ttl>"  . This is why I was thinking of populating an additional triple to import <file:b.ttl>. This might just be a workaround though.

It would be much appreciated if you could provide some suggestion about how to resolve <urn:x-evn-master:b> to a local file b.ttl, such that the external SHACL validator can run through without changing the persisted TTL files by the EDG git feature. 

Thanks.

Regards, Kai

Holger Knublauch

unread,
May 26, 2022, 10:00:12 PM5/26/22
to topbrai...@googlegroups.com

Hello Kai,

On 2022-05-27 5:43 am, Kai Liu wrote:
Thanks for the links and the info. 

I was talking about the EDG 7.2 feature "Commit Ontology to Git Repository". We found this feature extremely useful, and it saved us lots of tedious work of exporting, copying and renaming TTL files. With this feature, the "External Graph URI" of included sub-graph is not automatically persisted in the including sub-graph, however. 

Back to the origin of my question: I need to find a way to resolve <urn:x-evn-master:b> to a local file b.ttl, which was exported to the same directory as a.ttl in the git repository. I need to run the SHACL validator (https://github.com/TopQuadrant/shacl), which can not understand "<urn:x-evn-master:a> owl:imports <urn:x-evn-master:b>", but does understand  "<urn:x-evn-master:a> owl:imports <file:b.ttl>"  . This is why I was thinking of populating an additional triple to import <file:b.ttl>. This might just be a workaround though.

If you are running the SHACL API programmatically, there are various ways in which you can redirect owl:imports. For example using something like (untested)

            ontDocumentManager.addAltEntry("urn:x-evn-master:a", "file:///c:/a.ttl")

inserted into some place like

https://github.com/TopQuadrant/shacl/blob/master/src/main/java/org/topbraid/shacl/tools/AbstractTool.java#L76

Or just replace the owl:imports triples with file URIs as above. You state the latter didn't quite work, but what error did you get?

But these are more Jena API questions than TopBraid questions.

Holger


Kai Liu

unread,
May 27, 2022, 2:20:44 AM5/27/22
to TopBraid Suite Users
Hi Holger,

thanks for pointing out the jena API. Yes, this programmatic approach works. I was wondering whether there would be a way to solve this without using jena API. It seems that using API is the best way to do. 

  You state the latter didn't quite work, but what error did you get?
  -> replacing imports triples with file URIs as a post-processing step did work well.

Thanks a lot for your help.

Regards, Kai
Reply all
Reply to author
Forward
0 new messages