Re: how to get collections tree from xindice

Todd Byrne <[email protected]>
Newsgroups gmane.text.xml.xindice.user
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.