SPARQL query to identify Graph URI (ignore Included graphs)

106 views
Skip to first unread message

Dan Segal

unread,
Jun 22, 2023, 11:44:51 AM6/22/23
to TopBraid Suite Users
Hello,

I need to identify a Graph URI, or alternatively the metadata:idenfitier value, where the query returns only for the local graph, ignoring any included graphs.

For example:

SELECT ?graph ?id
WHERE {
?graph metadata:identifier ?id
  }

returns:

graph                             id
urn:x-evn-master:graph1           graph1
urn:x-evn-master:graph2           graph2
urn:x-evn-master:graph3           graph3

where:
  • graph1 is the local graph
  • graph2 and graph3 are Includes
  • The Graph URIs for all graphs are unknown in advance
How can I filter the query so that it returns only values from graph1, excluding values from graph2 and graph3?

Note: In EDG, checking "Return local results only" in the SPARQL Query panel returns the desired result.  However, I need to include the filtering syntax within the SPARQL query itself.

Thanks,

Dan
  


Holger Knublauch

unread,
Jun 22, 2023, 12:24:49 PM6/22/23
to topbrai...@googlegroups.com
Hi Dan,

you can use this fragment to get the "main" active graph

SELECT *
WHERE {
   BIND (teamwork:currentMasterGraph() AS ?graph) 
}

from the SPARQL endpoint and the SPARQL panel, assuming the currently active query graph is an asset collection.

Using this ?graph you can query fields like the metadata:identifier

HTH
Holger


--
The topics of this mailing list include TopBraid EDG and related technologies such as SHACL.
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/3e7f709f-57ec-4805-902d-4ce9ac0f71d6n%40googlegroups.com.

David Price

unread,
Jun 22, 2023, 12:56:58 PM6/22/23
to topbrai...@googlegroups.com
Normal SPARQL can do this too in the general case:

FILTER NOT EXISTS { ?graphx owl:imports ?graph . }

Cheers,
David

Holger Knublauch

unread,
Jun 22, 2023, 1:42:11 PM6/22/23
to topbrai...@googlegroups.com
Yes that's a more general solution that should also work well, except in cases of cyclic owl:imports where some other asset collection also happens to owl:import the main one.

Holger


Message has been deleted

Dan Segal

unread,
Jun 23, 2023, 3:12:53 PM6/23/23
to TopBraid Suite Users
Thank you, Holger and David for those suggestions.   Both very helpful...much appreciated!

Regards,

Dan

Reply all
Reply to author
Forward
0 new messages