xml-xindice-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Todd Byrne <by...@cns.montana.edu>
Subject Re: how to get collections tree from xindice
Date Wed, 25 May 2005 20:41:48 GMT
You can ask root collection db to list its child collections. Then just 
print them out.

Here is a small code example:

   public static void printCollections() throws Exception
   {
     Class c = 
Class.forName("org.apache.xindice.client.xmldb.DatabaseImpl");
     Database database = (Database)c.newInstance();
     DatabaseManager.registerDatabase(database);
     Collection col = DatabaseManager.getCollection(
         "xmldb:xindice://localhost:8080/db");
     Stack s = new Stack();
     s.push(col);
     while(!s.empty())
     {
       Collection current = (Collection)s.pop();
       System.err.println(current.getName());
       // list the collections..
       String subCollections[] = col.listChildCollections();
       for (int i = 0; i < subCollections.length; i++)
       {
         Collection child = current.getChildCollection(subCollections[i]);
         // some of the sub meta collections where null on my setup.
         if(child != null)
         {
           s.push(child);
         }
       }
     }
   }

Todd




Marcin Goldyn wrote:
> is there any possibility to get Collections tree from Xindice database??
> 
> Marcin Goldyn

Mime
View raw message