Here's how you create an embedded collection:
Collection col = null;
try {
String driver =
"org.apache.xindice.client.xmldb.embed.DatabaseImpl";
Class c = Class.forName(driver);
Database database = (Database) c.newInstance();
DatabaseManager.registerDatabase(database);
col =
DatabaseManager.getCollection("xmldb:xindice-embed:///db/");
String collectionName = "suprasphere";
CollectionManagementService service =
(CollectionManagementService)
col.getService("CollectionManagementService", "1.0");
// Build up the Collection XML configuration.
service.createCollection(collectionName);
System.out.println("Collection " + collectionName + " created.");
}
catch (XMLDBException e) {
System.err.println("XML:DB Exception occured " + e.errorCode);
}
catch (ClassNotFoundException cnfe) {
System.err.println("cnfe");
}
catch (InstantiationException ie) {
System.err.println("ie");
}
catch (IllegalAccessException iae) {
System.err.println("iae");
}
finally {
if (col != null) {
try {
col.close();
}
catch (XMLDBException e) {
System.err.println("XML:DB Exception occured in closing" +
e.errorCode);
}
}
}