The closest I get is the following SPARQL query:
> SELECT DISTINCT ?subj ?label
> WHERE {
> GRAPH ?graph {
> ?subj ?pred ?obj .
> OPTIONAL {
> ?subj ?labelPred ?label .
> FILTER (
> (?labelPred = <http://www.w3.org/2000/01/rdf-schema#label>) #
> (1)
> )
> FILTER( isLiteral(?label) )
> }
> }
> FILTER (?graph = <http://hypergraphs.de/TestGraph>)
> }
> ORDER BY ?label ?subj
Comments:
- This solution also works for multiple label predicates (i.e., if there are
subproperties of rdfs:label), then the unary disjunction (1) has more
components.
- ?graph is necessary, because Sesame does not support datasets and I want to
restrict the query to all graphs that are currently "visible".
- This query returns unlabeled resources first (?label is unbound), then
labeled resources. Better would be to show labeled resources first. Best would
be to mix them, where unlabeled resources are sorted according to their qname.
Can this be improved?
Thanks for any comments or suggestions...
Axel
--
[email protected]
http://www.pst.ifi.lmu.de/~rauschma/