Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[protege-discussion] programmatic queries

Jonathan Carter jonathan.carter at e-asolutions.com
Thu Nov 13 16:12:01 PST 2008


Hi Jason,

To make queries, you have to write code to do the query, e.g. in  
Python your query would be something like:

c = kb.getCls("ClassName")
instanceList = kb.getDirectInstances(c)
for instance in instanceList:
	number = instance.getDirectOwnSlotValue(kb.getSlot("number"))
	if number = 3:
		return instance

or something along those lines.

I've found that it's not very different if you use XSLT against the  
XML produced by the 'Experimental XML Format' project format (there's  
an option in the File menu for this) but you might find that the  
syntax is a bit more query-like.

Also the Query Tab is definitely worth checking out. You can do what  
you just described below (find all instances of class 'c' whose slot  
'number' is 3) in 3 clicks. You can also add clauses to build AND and  
ORs in there and very neatly, you can sort of do joins by performing a  
query, saving it and then using it as the test value in your query  
(the '3' in your example). So, I could save all the 'c's that have  
number = 3 and then use this result set as the test for another query.
Obviously, this only works when you're at the GUI in the Query Tab,  
not in the API (although, I suppose it's possible).

Regards

Jonathan
__________________________________________
Jonathan Carter - Head of Technical Architecture
Enterprise Architecture Solutions Ltd
__________________________________________

Assess your EA maturity at:
www.enterprise-architecture.com/EAvaluator
__________________________________________

On 13 Nov 2008, at 20:01, Jason Sachs wrote:

> I am very confused... how do you make programmatic queries via the  
> API? There's a Query class but it doesn't seem to have any methods,  
> just static constants.
>
> e.g. if I have a particular class in a variable "c", how would I get  
> all instances which have slots named "number" having a value of "3"?
> _______________________________________________
> protege-discussion mailing list
> protege-discussion at lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/protege-discussion
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/protege-discussion/attachments/20081114/440158eb/attachment.html>


More information about the protege-discussion mailing list