I am trying to manipulate an xml document i placed within the addressbook collection in Xindice(Native XML Database). I'm attempting to match the value contained within the email attribute in the departmental-office element. The program compiles but I'm not getting any output. Can you see where I'm going wrong?
Many thanks,
David
import org.xmldb.api.base.*;
import org.xmldb.api.modules.*;
import org.xmldb.api.*;
public class test {
public static void main(String[] args) throws Exception {
Collection col = null;
try {
String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
Class c = Class.forName(driver);
Database database = (Database) c.newInstance();
DatabaseManager.registerDatabase(database);
col = DatabaseManager.getCollection("xmldb:xindice:///db/addressbook"
String xpath = "//Departmental_Office";
XPathQueryService service =
(XPathQueryService) col.getService("XPathQueryService", "1.0"
ResourceSet resultSet = service.query(xpath);
ResourceIterator results = resultSet.getIterator();
while (results.hasMoreResources()) {
Resource res = results.nextResource();
System.out.println((String) res.getContent());
}
}
catch (XMLDBException e) {
System.err.println("XMLB Exception occured " + e.errorCode);
}
finally {
if (col != null) {
col.close();
}
}
}
}
Many thanks,
David
import org.xmldb.api.base.*;
import org.xmldb.api.modules.*;
import org.xmldb.api.*;
public class test {
public static void main(String[] args) throws Exception {
Collection col = null;
try {
String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
Class c = Class.forName(driver);
Database database = (Database) c.newInstance();
DatabaseManager.registerDatabase(database);
col = DatabaseManager.getCollection("xmldb:xindice:///db/addressbook"
String xpath = "//Departmental_Office";
XPathQueryService service =
(XPathQueryService) col.getService("XPathQueryService", "1.0"
ResourceSet resultSet = service.query(xpath);
ResourceIterator results = resultSet.getIterator();
while (results.hasMoreResources()) {
Resource res = results.nextResource();
System.out.println((String) res.getContent());
}
}
catch (XMLDBException e) {
System.err.println("XMLB Exception occured " + e.errorCode);
}
finally {
if (col != null) {
col.close();
}
}
}
}