TK; It's not entirely clear from the description what the count is
for, but using an aggregate may be an effective way to do this. The
following gets all subclasses of owl:Thing and a count of the number
of subclasses.
SELECT ?cls (count(?subc) as ?subClasses)
WHERE {
?cls rdfs:subClassOf+ owl:Thing .
OPTIONAL {?subc rdfs:subClassOf ?cls .}
} GROUP BY ?cls
Note I've also used the transitive extension ('+') to explicitly state
that I'm looking for all subclasses of owl:Thing. As Holger states,
this only works in a SPARQLMotion script if all classes have a
subClassOf statement.
-- Scott
On Dec 18, 11:23 pm, Holger Knublauch <[email protected]> wrote:
> Please make sure that the file explicitly asserts all rdfs:subClassOf
> triples. When you open files in TBC, the system will add "trivial" inferences
> to make sure that each named class has at least one named superclass. These
> are then inferred triples, which would not be available by default if your
> file is loaded through SPARQLMotion. Also, you may want to import the system
> triples to get the same environment like in TBC.
>
> In your query below I don't understand the use of ?arg2. Furthermore, the use
> of the rather ugly (legacy) function smf:countResults could be replaced with
> a SPIN function such as spl:objectCount.
>
> Regards,
> Holger
>
> On Dec 18, 2009, at 2:31 PM, TKC wrote:
>
> > I have written a SparqlMotion script that imports an ontology, say
> > "Main," using the "Import RDF From Workspace" module. (Now, "Main,"
> > itself, imports several sub-ontologies.) Following this module, I have
> > a Sparql query that attempts to retrieve all subclasses of
> > "owl:Thing"--from "Main" and from all ontologies that "Main" imports.
> > Why am I getting only a partial listing of subclasses?
>
> > The query I run after the import looks like this:
>
> > SELECT ?subject ?subClasses
> > WHERE {
> > ?subject rdfs:subClassOf ?object .
> > LET (?object := smf:buildURI("{?arg2}")) .
> > LET (?subClasses := smf:countResults("SELECT * WHERE {?x
> > rdfs:subClassOf ?subject}")) .
> > }
>
> > My SparqlMotion script is intended to be a Web service behind a Flex
> > tree that shows classes and their parentage within a federated
> > ontology. Rather than build an entire ontology into the tree, I want
> > to lessen the load on the client by only fetching sublcasses when a
> > user clicks to expand a node.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "TopBraid Composer Users" group.
> > To post to this group, send email to
> > [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group
> > athttp://groups.google.com/group/topbraid-composer-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"TopBraid Composer Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/topbraid-composer-users?hl=en.