W3C home > Mailing lists > Public > semantic-web@w3.org > January 2006

Query properties of a resource with SPARQL

From: Jeremy Wong 黃泓量 <jeremy@miko.hk>
Date: Thu, 12 Jan 2006 17:35:13 +0800
Message-ID: <002501c6175b$7d300680$6802a8c0@miko.hk.local>
To: "Semantic Web" <semantic-web@w3.org>

Below is a SPARQL query to retrieve pairs of resource and resource's 
property (when the resource acts as subject). It is to find out whether the 
set of rdfs:domain of a rdf:Property is a subset of the set of rdfs:Class of 
a resource. It looks so lengthy... Any way to improve the query?

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?r0 ?property{
    ?r0 a ?c0.
    ?property rdfs:domain ?c0.
    OPTIONAL{
        ?property rdfs:domain ?c1.
        FILTER(?c1=?c0)
        OPTIONAL{
            ?property rdfs:domain ?c2a.
            FILTER(?c2a!=?c1)
        }
        FILTER(BOUND(?c2a))
        OPTIONAL{
            ?property rdfs:domain ?c2.
            FILTER(?c2!=?c1)
            OPTIONAL{
                ?r2 a ?c2
            }
            FILTER(?r2=?r0)
        }
        FILTER(!BOUND(?r2))
    }
    FILTER(!BOUND(?c1))
}



Regards,
Jeremy Wong 黃泓量
--
Miko-Kings Instruments Ltd.
Web: http://www.miko.com.hk/ 
Received on Thursday, 12 January 2006 09:36:56 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:47:11 UTC