Get all classes of an ontology

55 views
Skip to first unread message

umar farooq

unread,
Feb 10, 2012, 5:56:19 AM2/10/12
to TopBraid Suite Users
Hello everyone,
I want to show all classes of ontology in tree
form in web based J2EE application. So i have some confusions. What
would be sparql query for that and how to iterate the data to show the
results in tree form..

Scott Henninger

unread,
Feb 10, 2012, 10:26:27 AM2/10/12
to TopBraid Suite Users
Umar; the following query will get all subclasses of owl:Thing. If
you want subclasses of some other class, just replace owl:Thing with
the URI of the class.

SELECT ?cls
WHERE
{ ?cls rdfs:subClassOf* owl:Thing .
}


If you don't want to include owl:Thing in the results, use '+' instead
of '*'.

Both TopBraid Composer and Ensemble provide out-of-the-box components
to display subclass trees. Ensemble runs in a J2EE application
server. See http://www.topquadrant.com/products/TB_Ensemble.html, and
you can display tree structures of any object property. Enterprise
Vocabulary Net (http://www.topquadrant.com/solutions/
ent_vocab_net.html) display tree structures for SKOS vocabularies.

-- Scott

umar farooq

unread,
Feb 11, 2012, 3:02:50 AM2/11/12
to topbrai...@googlegroups.com
Butt dear Scott it is not not working.. 
I am trying this..
"Select ?uri"+
" WHERE { "+
"?uri    rdfs:subClassOf* owl:Pizza . " +
"}";

should it return all the subclasses of Pizza and subclasses of pizza's subclasses in tree hierarchy..
i want result in the following form. What should i do.??
Pizza
      subofpizza1
                subofsubofpizza1
                subofsubofpizza2
      subofpizza2
                subofsubofpizza1
                subofsubofpizza2
      subofpizza3


AND thanks for help :)


--
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary Network (EVN), TopBraid Composer,
TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN.
To post to this group, send email to
topbrai...@googlegroups.com
To unsubscribe from this group, send email to
topbraid-user...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en



--
Best Regards,
Umar

Scott Henninger

unread,
Feb 11, 2012, 11:01:34 AM2/11/12
to TopBraid Suite Users
Umar; What TopBraid product are you using? If you want to display
class structures in a Web application, I'd suggest TopBraid Ensemble.
To try this on a desktop, start TBC-ME, which includes a localhost
server. Then open a browser to http://localhost:8083/tbl, choose
Default Application, and choose you data graph. The hierarchy will
appear in the upper-left view.

You can find more at Help > TopBraid Live Integration (ME).

-- Scott

On Feb 11, 2:02 am, umar farooq <umarfarooq...@gmail.com> wrote:
> Butt dear Scott it is not not working..
> I am trying this..
> "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "+
> "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> " +
> "PREFIX owl:<http://www.w3.org/2002/07/owl#> " +
> "Select ?uri"+
> " WHERE { "+
> "?uri    rdfs:subClassOf* owl:Pizza . " +
> "}";
>
> should it return all the subclasses of Pizza and subclasses of pizza's
> subclasses in tree hierarchy..
> i want result in the following form. What should i do.??
> Pizza
>       subofpizza1
>                 subofsubofpizza1
>                 subofsubofpizza2
>       subofpizza2
>                 subofsubofpizza1
>                 subofsubofpizza2
>       subofpizza3
>
> AND thanks for help :)
>
> On Fri, Feb 10, 2012 at 7:26 AM, Scott Henninger <shennin...@topquadrant.com
>
>
>
>
>
>
>
>
>
> > wrote:
> > Umar; the following query will get all subclasses of owl:Thing.  If
> > you want subclasses of some other class, just replace owl:Thing with
> > the URI of the class.
>
> > SELECT ?cls
> > WHERE
> > {  ?cls rdfs:subClassOf* owl:Thing .
> > }
>
> > If you don't want to include owl:Thing in the results, use '+' instead
> > of '*'.
>
> > Both TopBraid Composer and Ensemble provide out-of-the-box components
> > to display subclass trees.  Ensemble runs in a J2EE application
> > server. Seehttp://www.topquadrant.com/products/TB_Ensemble.html, and
> > you can display tree structures of any object property.  Enterprise
> > Vocabulary Net (http://www.topquadrant.com/solutions/
> > ent_vocab_net.html) display tree structures for SKOS vocabularies.
>
> > -- Scott
>
> > On Feb 10, 5:56 am, umar farooq <umarfarooq...@gmail.com> wrote:
> > > Hello everyone,
> > >                      I want to show all classes of ontology in tree
> > > form in web based J2EE application. So i have some confusions. What
> > > would be sparql query for that and how to iterate the data to show the
> > > results in tree form..
>
> > --
> > You received this message because you are subscribed to the Google
> > Group "TopBraid Suite Users", the topics of which include Enterprise
> > Vocabulary Network (EVN), TopBraid Composer,
> > TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN.
> > To post to this group, send email to
> > topbrai...@googlegroups.com
> > To unsubscribe from this group, send email to
> > topbraid-user...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/topbraid-users?hl=en
>
> --
> *Best Regards,
> Umar*

umar farooq

unread,
Feb 11, 2012, 12:02:23 PM2/11/12
to topbrai...@googlegroups.com
Dear Scott.
                I am using J2EE and RESTfull web services. but here i just need sparql query that return result in N-Triple,XML or JSON  format so that i can iterate on that on client side .
Best Regards,
Umar

Scott Henninger

unread,
Feb 11, 2012, 12:54:57 PM2/11/12
to TopBraid Suite Users
Umar; You can read about creating Web services in our FAQ at
www.topquadrant.com/products/TBS_FAQ.html#TBS3. There is also a
section on Web services in the TopBraid Ensemble Application
Development Guide found in the More Information section of
http://www.topquadrant.com/products/TB_Ensemble.html. There is also a
working example at http://www.topquadrant.com/products/SPARQLMotion_docs/SPARQLMotion_ex_dbpediaCapitals.html

The Web service call would invoke a SPARQLMotion script on the TBL
server. You could design that script to use the
sml:ReturnSPARQLResults module. This will submit a query and return
the results in a **SPARQL endpoint** formats. XML, Turtle, NTriples,
JSON, and other formats are supported. From the client perspective,
you have many choices. One is to use a query such as the following:

SELECT ?s ?p ?o
WHERE
{ ?s ?p ?o .
FILTER (?p = rdfs:subClassOf)
}

This would get all rdfs:subClassOf relationships and your client code
can render the tree. Another is to pass a parameter to the script
representing the root. The client can iterate through the tree,
getting the children of each root and then getting the children of the
resources returned to build the tree. The query in that case would be
(assuming ?root is passed in the Web service call):

SELECT ?child
WHERE
{ ?child rdfs:subClassOf ?root
}

That's about all we can really get into on this forum. Our concern in
this forum is on building a semantic service layer. UI implementation
is a service we provide for our customers through Ensemble, Composer,
Enterprise Vocabulary Network (EVN) and SPARQL Web Pages. Writing the
UI code for rendering trees, etc., goes beyond the scope of this forum
in most cases (a possible exception is if someone wanted to know how
to render a tree in SWP).

-- Scott

On Feb 11, 11:02 am, umar farooq <umarfarooq...@gmail.com> wrote:
> Dear Scott.
>                 I am using J2EE and RESTfull web services. but here i just
> need sparql query that return result in N-Triple,XML or JSON  format so
> that i can iterate on that on client side .
>
> On Sat, Feb 11, 2012 at 8:01 AM, Scott Henninger <shennin...@topquadrant.com
>
>
>
>
>
>
>
>
>
> > wrote:
> > Umar; What TopBraid product are you using?  If you want to display
> > class structures in a Web application, I'd suggest TopBraid Ensemble.
> > To try this on a desktop, start TBC-ME, which includes a localhost
> > server.  Then open a browser tohttp://localhost:8083/tbl, choose
> *Best Regards,
> Umar*

Holger Knublauch

unread,
Feb 11, 2012, 5:01:29 PM2/11/12
to topbrai...@googlegroups.com
On Feb 12, 2012, at 3:02 AM, umar farooq wrote:

Dear Scott.
                I am using J2EE and RESTfull web services. but here i just need sparql query that return result in N-Triple,XML or JSON  format so that i can iterate on that on client side .

For examples of Ajax trees using SPARQL Web Pages (SWP), start the new 3.6 beta and open


in a web browser. This demonstrates the built-in swa:Tree element, e.g. insert
<swa:Tree arg:dataProvider="swa:ClassTreeDataProvider" arg:id="classTree" arg:root="owl:Thing"/>
into an SWP document. This produces

swa:Tree does lazy loading, i.e. instead of downloading all nodes at once (which may not scale), it loads nodes on demand.

BTW SWP can also be used to write REST services that generate arbitrary server-side result documents from SPARQL queries, e.g. a JSON tree structure. Let me know if you need details.

Regards,
Holger


Reply all
Reply to author
Forward
0 new messages