Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to find objects that reference another object in SPARQL
    primarykey
    data
    text
    <p>First of all I must apologize since I am very new when it comes to XML, RDF and SPARQL queries. All my knowledge is based on 3 days of much reading so it has not fully sunk in. Nevertheless, a problem I encountered when trying to query a large RDF file using Jena was <strong>how to get all instances that are part of a superclass</strong>?</p> <p>Sorry if this is badly worded so here is an example. In my RDF file, there is always a main node:</p> <p> The Main Node </p> <p>and then there are objects that have this node as a resource like:</p> <pre class="lang-xml prettyprint-override"><code>&lt;cim:Connection rdf:ID="connection_1"&gt; &lt;cim:Object.name&gt;Connection Point 1&lt;/cim:Object.name&gt; &lt;cim:Connection.node rdf:resource="#main_node_1"/&gt; &lt;/cim:Connection&gt; </code></pre> <p>or</p> <pre class="lang-xml prettyprint-override"><code>&lt;cim:Potential rdf:ID="potential_1"&gt; &lt;cim:Object.name&gt;Equal Potential 1&lt;/cim:Object.name&gt; &lt;cim:Potential.node rdf:resource="#main_node_1"/&gt; &lt;/cim:Connection&gt; </code></pre> <p>Now I know how to query for any <code>rdf:type</code> and (a bit) how to graph query using SPARQL. What I want to do is 1st find the MainNode (which I already can) and then find all elements/objetcs/classes/instances that reference to this MainNode.</p> <p>With my current attempts I can query for a <code>Connection</code> or <code>Potential</code> directly, but not for both. So the query returning all <code>Connection</code>s would be:</p> <pre><code>PREFIX rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; PREFIX cim: &lt;http://iec.ch/TC57/2010/CIM-schema-cim15#&gt; SELECT ?object WHERE { ?object cim:Connection.node ?mainNode . ?mainNode cim:Object.name "The Main Node" . } </code></pre> <p>and for all <code>Potential</code>s the query would be:</p> <pre><code>PREFIX rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; PREFIX cim: &lt;http://iec.ch/TC57/2010/CIM-schema-cim15#&gt; SELECT ?object WHERE { ?object cim:potential.node ?mainNode . ?mainNode cim:Object.name "The Main Node" . } </code></pre> <p>Yet I need to extract both and do not want to use <code>UNION</code> since there may be more classes that I have not included. My attempt was to change the <code>?object</code> line to:</p> <pre><code>?mainNode cim:*.name "The Main Node" . </code></pre> <p>yet the asterisk <code>*</code> does not allow me to make any class available here. In fact, both <code>Connection</code> and <code>Potential</code> could be seen as children of a superclass that contains the variable <code>node</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload