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-owl] Protege OWL API- Web application

JibeCC jacques.barzic at 289eme.fr
Sun Aug 24 02:54:51 PDT 2008


Hi,
after other documentation reading, I find a solution to make a recursive
call on the OWLmodel.
I copy here a Java method to print the classes tree. This method can be
adapted for other using.
Perhaps this may appear simple, but if it can be util for beginners as
me...;-)

 	/**
	 * Print on the standard out the classes tree. Starting at a specified
class and for a specified number of levels. 
	 * Thanks to following sources :
	 * - http://protege.stanford.edu/plugins/owl/api/guide.html#OWLNamedClasses
	 * -
http://jena.sourceforge.net/examples/class-hierarchy/ClassHierarchy.java.html
	 * 
	 * @param cl The class what is the point of start.
	 * @param anonymous true if anonymous classes must be edit.
	 * @param indirect true if indirect instance must be edit.
	 * @param occurs An empty List. it's used to prevent getting stuck in a
loop.
	 * @param indentation Indentation for the first level. The indentaion of
the deaper levels are adding to it. 
	 * @param levels The number of levels are calculate(within the level of the
started class).
	 */public void printClassesTree(RDFSClass cl, boolean anonymous, boolean
indirect, List occurs, String indentation, int level){		
		level = level - 1;
		System.out.println(indentation + cl.getName());
		if (cl.canAs(RDFSClass.class)  &&  !occurs.contains(cl) && level > 0) {
			if(anonymous == false){
				for(java.util.Iterator it = cl.getNamedSubclasses(indirect).iterator();
it.hasNext();){
					 RDFSClass subClass = (RDFSClass) it.next();				 
					 occurs.add(cl);		             		             
					 printClassesTree(subClass, anonymous, indirect, occurs , indentation +
"   ", level);
		                         occurs.remove(cl);
				 }				
			}else{
				for(java.util.Iterator it = cl.getSubclasses(indirect).iterator();
it.hasNext();){
					 RDFSClass subClass = (RDFSClass) it.next();				 
					 occurs.add(cl);
					 printClassesTree(subClass, anonymous, indirect, occurs , indentation +
"   ", level);
		                         occurs.remove(cl);
				 }				
			}			 
		}
	}



JibeCC wrote:
> 
> Hi all,
> I develope a Java web application with Myfaces for the presentation 
> layer. 
> I use the Protege-OWL API for the data access in a owl file make with
> Protege-OWL. 
> I want to diplay the OWL tree (not each time start at the owl:Thing, but
> also start at a specified class) from an owl file, like in the Class tab
> in Protégé.
> For this I must querry the class tree.
> I've seen on the wiki the solution for a Java application, but I don't
> find solution to do this for an another type of display (web in my case).
> In fact, I need a Collection (of Collections indeed) to use it in the HTML
> tree (through Tomahawk tree).
> is there a solution ?
> Tanks,
> JibeCC
> 
> 

-- 
View this message in context: http://www.nabble.com/Protege-OWL-API--Web-application-tp19108377p19129196.html
Sent from the Protege - OWL mailing list archive at Nabble.com.




More information about the protege-owl mailing list