You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by "Vladimir R. Bossicard" <vl...@bossicard.com> on 2002/10/20 20:19:37 UTC
Servlet for Xindice
I'm currently debugging the XindiceServlet class (and it's NPE bug) to
prepare Xindice 1.1. The goal is to have a simple database browser (no
update, just retrieve) servlet.
If you have already programmed such a servlet could you please send me
the code so that I can speed up the development.
Thanks,
-Vladimir
--
Vladimir R. Bossicard
www.bossicard.com
Re: Servlet for Xindice
Posted by Devrim Ergel <de...@parsera.com>.
Below is the function that we use to retrieve with xpath, no difference from
applications. I put it DBHelper class and all servlets use
the same function. For some servlets (if there is speed need) we use
collection pooling.
PS: Function transforms retrieved w3c elements to Dom4J
Devrim
private static String driver =
"org.apache.xindice.client.xmldb.DatabaseImpl";
private static String dbString = "xmldb:xindice://localhost:4080/db/";
public static Vector load(String XPathQuery, String collection) throws
Exception{
Collection col = null;
DefaultElement defaultElement = null;
Vector elementVector = new Vector();
// Does the record exist in the database
try {
Class c = Class.forName(driver);
Database database = (Database) c.newInstance();
DatabaseManager.registerDatabase(database);
col = DatabaseManager.getCollection(dbString + collection);
XPathQueryService service = (XPathQueryService)
col.getService("XPathQueryService", "1.0");
ResourceSet resultSet = service.query(XPathQuery);
ResourceIterator results = resultSet.getIterator();
while (results.hasMoreResources()) {
XMLResource res = (XMLResource) results.nextResource();
org.w3c.dom.Node node = res.getContentAsDOM();
org.dom4j.Document doc = W3E2dom4jDocument(node);
Element element = doc.getRootElement();
elementVector.add(element);
}
}
catch (XMLDBException e) {
System.err.println("XML:DB Exception occured " + e.errorCode);
return null;
}
finally {
if (col != null)
try {
col.close();
}
catch (XMLDBException e) {
System.err.println("XML:DB Exception occured " +
e.errorCode);
return null;
}
return elementVector;
}
}
----- Original Message -----
From: "Vladimir R. Bossicard" <vl...@bossicard.com>
To: "Xindice Users" <xi...@xml.apache.org>
Sent: Sunday, October 20, 2002 9:19 PM
Subject: Servlet for Xindice
> I'm currently debugging the XindiceServlet class (and it's NPE bug) to
> prepare Xindice 1.1. The goal is to have a simple database browser (no
> update, just retrieve) servlet.
>
> If you have already programmed such a servlet could you please send me
> the code so that I can speed up the development.
>
> Thanks,
>
> -Vladimir
>
> --
> Vladimir R. Bossicard
> www.bossicard.com
>