import org.xmldb.api.DatabaseManager; import org.xmldb.api.base.Collection; import org.xmldb.api.base.Database; import org.xmldb.api.base.XMLDBException; import org.xmldb.api.modules.XUpdateQueryService; /** * Simple XML:DB API example to update the database. */ public class XUpdate { public static void main(String[] args) throws Exception { String driver = "org.apache.xindice.client.xmldb.DatabaseImpl"; String collection = "xmldb:xindice:///db/addressbook"; String xupdate = "" + " " + " " + " 480-300-3003" + " " + ""; Collection col = null; try { Class c = Class.forName(driver); Database database = (Database) c.newInstance(); DatabaseManager.registerDatabase(database); col = DatabaseManager.getCollection(collection); XUpdateQueryService service = (XUpdateQueryService) col.getService( "XUpdateQueryService", "1.0"); service.update(xupdate); } catch (XMLDBException e) { System.err.println( "XML:DB Exception occured " + e.errorCode + " " + e.getMessage()); } finally { if (col != null) { col.close(); } } } }